Annotation Type Marshalled


Annotation that can be applied to classes to control how they are marshalled.

Can be used in the following locations:

  • Marshalled classes.
  • @Rest-annotated classes and @RestOp-annotated methods when an on() value is specified.

This annotation is typically only applied to non-bean classes. The @Bean annotation contains equivalent functionality for bean classes.

See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    POJO example.
    Implementation class.
    Dynamically apply this annotation to the specified classes.
    Class<?>[]
    Dynamically apply this annotation to the specified classes.
  • Element Details

    • example

      POJO example.

      Specifies an example of the specified class in Simplified JSON format.

      Examples are used in cases such as POJO examples in Swagger documents.

      Example:

      @Marshalled(example="{foo:'bar'}") public class MyClass {...}

      Notes:
      • Setting applies to specified class and all subclasses.
      • Keys are the class of the example.
        Values are JSON 5 representation of that class.
      • POJO examples can also be defined on classes via the following:
        • A static field annotated with @Example.
        • A static method annotated with @Example with zero arguments or one BeanSession argument.
        • A static method with name example with no arguments or one BeanSession argument.
      • Supports VarResolver.DEFAULT (e.g. "$C{myConfigVar}").
      See Also:
      Returns:
      The annotation value.
      Default:
      ""
    • implClass

      Implementation class.

      For interfaces and abstract classes this method can be used to specify an implementation class for the interface/abstract class so that instances of the implementation class are used when instantiated (e.g. during a parse).

      Example:

      @Marshalled(implClass=MyInterfaceImpl.class) public class MyInterface {...}

      Returns:
      The annotation value.
      Default:
      void.class
    • on

      Dynamically apply this annotation to the specified classes.

      Used in conjunction with BeanContext.Builder.applyAnnotations(Class...) to dynamically apply an annotation to an existing class. It is ignored when the annotation is applied directly to classes.

      The following example shows the equivalent methods for applying the @Bean annotation to REST methods:

      // Class with explicit annotation. @Marshalled(example="{foo:'bar'}") public class A {...} // Class with annotation applied via @BeanConfig public class B {...} // Java REST method with @BeanConfig annotation. @RestOp(...) @Marshalled(on="B", example="{foo:'bar'}") public void doFoo() {...}

      Valid patterns:
      • Classes:
        • Fully qualified:
          • "com.foo.MyClass"
        • Fully qualified inner class:
          • "com.foo.MyClass$Inner1$Inner2"
        • Simple:
          • "MyClass"
        • Simple inner:
          • "MyClass$Inner1$Inner2"
          • "Inner1$Inner2"
          • "Inner2"
      • A comma-delimited list of anything on this list.
      See Also:
      Returns:
      The annotation value.
      Default:
      {}
    • onClass

      Dynamically apply this annotation to the specified classes.

      Identical to on() except allows you to specify class objects instead of a strings.

      See Also:
      Returns:
      The annotation value.
      Default:
      {}