Annotation Interface ProtoAdapter


@Target(TYPE) @Retention(RUNTIME) @Documented public @interface ProtoAdapter
A marshalling adapter for a target class or enum that cannot be annotated for various reasons. This class will handle the schema definition and marshalling for the target by declaring a protobuf schema via annotations.
This class will not become marshallable! It is the target class that becomes marshallable.

When used on classes:
The class bearing this annotation will have an annotated factory method for the marshalled class and annotated accessor methods for each field. These methods can be instance or static methods and their first argument must be the marshalled class. Annotations must be placed only on methods. Direct field annotations are not allowed.

This class must be thread-safe and stateless and must have an accessible no argument constructor. A single instance of it will be created per SerializationContext.

When used on enums:
For each enum value in this enum there must exist en identically named enum value in the target enum.

Since:
4.4
Author:
[email protected]
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The actual class being marshalled.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Any sub-classes of the main class specified by value() which should also be handled by this adapter.
  • Element Details

    • value

      Class<?> value
      The actual class being marshalled.
    • subClassNames

      String[] subClassNames
      Any sub-classes of the main class specified by value() which should also be handled by this adapter. This is useful, for example, when implementing an adapter for an interface, but the actual implementation class is determined by a factory method, such as List.of(). This element uses names instead of actual classes so that it is possible to specify non-public classes.
      Default:
      {}