Annotation Interface MarshalledProp


Used to tailor how bean properties get marshalled by the framework.

The marshalling-only sibling of @BeanProp. Where @BeanProp (in juneau-commons) carries the bean-modeling attributes (such as name, ro, wo, type, params, elementType, and factory), this annotation carries the wire-format-specific attributes used by serializers and parsers: a per-property format string and a bean dictionary for polymorphic types.

Can be used in the following locations:

  • Methods/Fields - Bean getters/setters and properties.
  • @Rest-annotated classes and @RestOp-annotated methods when used with @MarshalledPropApply.

This annotation does not support renaming a property, nor the read-only/write-only, concrete-type, generic-params, element-type, or bean-factory attributes — those are bean-modeling concerns that live on @BeanProp instead. To rename a property, use @BeanProp (e.g. @BeanProp("newName")), not this annotation.

See Also:
  • Element Details

    • description

      Optional description for the exposed API.
      Returns:
      The annotation value.
      Since:
      9.2.0
      Default:
      {}
    • view

      Declares the named views this property belongs to.

      When an active view is selected (via MarshallingContext.Builder.activeView(String) or the per-call session override), this property is included only when its declared view set contains the active view name.

      If this member is empty (the default), the property follows the default-view-inclusion policy: by default an untagged property is included under every active view (matching Jackson's DEFAULT_VIEW_INCLUSION behavior). The policy can be flipped via MarshallingContext.Builder.disableDefaultViewInclusion().

      Multiple view names are supported — a property tagged view={"summary","detail"} is included when either "summary" or "detail" is the active view (union semantics).

      Example:

      public class MyBean { // Included in all views (untagged = default inclusion) public String id; // Included only in the "summary" and "detail" views @MarshalledProp(view={"summary", "detail"}) public String name; // Included only in the "detail" view @MarshalledProp(view="detail") public String description; }

      See Also:
      Returns:
      The annotation value.
      Since:
      10.0.0
      Default:
      {}
    • dictionary

      Bean dictionary.

      The list of classes that make up the bean dictionary for this bean property, used during polymorphic marshalling.

      See Also:

      This annotation can also be used on private fields of a property.

      Returns:
      The annotation value.
      Default:
      {}
    • calendarFormat

      Calendar wire format override.
      Returns:
      The annotation value.
      Default:
      NOT_SET
    • dateFormat

      Date wire format override.
      Returns:
      The annotation value.
      Default:
      NOT_SET
    • durationFormat

      Duration wire format override.
      Returns:
      The annotation value.
      Default:
      NOT_SET
    • format

      Specifies a String format for converting the bean property value to a formatted string.

      Note that this is usually a one-way conversion during serialization.

      During parsing, we will attempt to convert the value to the original form by using the MarshallingSession.convertToType(Object, Class) but there is no guarantee that this will succeed.

      Example:

      @MarshalledProp(format="$%.2f") public float price;

      This annotation can also be used on private fields of a property like so:

      Example:

      public class MyBean { @MarshalledProp(format="$%.2f") private float price; public float getPrice() { return price; } }

      Returns:
      The annotation value.
      Default:
      ""
    • localeFormat

      Locale wire format override.
      Returns:
      The annotation value.
      Default:
      NOT_SET
    • periodFormat

      Period wire format override.
      Returns:
      The annotation value.
      Default:
      NOT_SET
    • temporalFormat

      Temporal wire format override.
      Returns:
      The annotation value.
      Default:
      NOT_SET
    • timeZoneFormat

      Time-zone wire format override.
      Returns:
      The annotation value.
      Default:
      NOT_SET
    • binaryFormat

      Binary wire format override for byte[] property values.
      Returns:
      The annotation value.
      Default:
      NOT_SET
    • enumFormat

      Enum wire format override for Enum property values.
      Returns:
      The annotation value.
      Default:
      NOT_SET
    • uuidFormat

      UUID wire format override for UUID property values.
      Returns:
      The annotation value.
      Default:
      NOT_SET
    • bitSetFormat

      BitSet wire format override for BitSet property values.
      Returns:
      The annotation value.
      Default:
      NOT_SET
    • bigNumberFormat

      Big-number wire format override for BigInteger / BigDecimal property values.
      Returns:
      The annotation value.
      Default:
      NOT_SET
    • booleanFormat

      Boolean wire format override for Boolean / boolean property values.
      Returns:
      The annotation value.
      Default:
      NOT_SET
    • floatFormat

      Float / Double non-finite wire format override for Float / Double property values.
      Returns:
      The annotation value.
      Default:
      NOT_SET
    • currencyFormat

      Currency wire format override for Currency property values.
      Returns:
      The annotation value.
      Default:
      NOT_SET
    • classFormat

      Class wire format override for Class property values.
      Returns:
      The annotation value.
      Default:
      NOT_SET
    • nulls

      Per-property null-coercion policy applied when a null JSON-equivalent value reaches this property during parsing.

      Juneau's analog of Jackson's @JsonSetter(nulls=…). When the parser encounters an explicit null (or an absent Optional) for this property, the configured policy decides whether to:

      • LEAVE (default) — set the property to null (or, for an Optional-typed property, to Optional.empty()).
      • EMPTY — substitute the type's "empty" value (empty String/Collection/ Map, primitive default for primitives, Optional.empty() for Optional).
      • DEFAULT — substitute the bean-constructed default for the property (i.e. the value the property holds on a fresh no-arg-constructed instance of the bean). When no reference instance can be built, falls back to LEAVE.
      • SKIP — do not call the setter at all, leaving any pre-existing value in place.

      For an Optional-typed property, EMPTY/DEFAULT resolve to Optional.empty() — never a bare null inside an Optional. The same contract applies to OptionalInt, OptionalLong, and OptionalDouble.

      When this member is NOT_SET (the default), the context-level default configured on Parser.Builder.nulls(Nulls) applies.

      Returns:
      The annotation value.
      Since:
      10.0.0
      Default:
      NOT_SET