java.lang.Object
tools.jackson.dataformat.protobuf.schema.ProtobufSchema
All Implemented Interfaces:
tools.jackson.core.FormatSchema

public class ProtobufSchema extends Object implements tools.jackson.core.FormatSchema
A FormatSchema implementation for protobuf, bound to specific root-level ProtobufMessage, and useful for reading/writing protobuf content that encodes instance of that message.
  • Field Details

    • FORMAT_NAME_PROTOBUF

      public static final String FORMAT_NAME_PROTOBUF
      See Also:
    • _source

      protected final NativeProtobufSchema _source
      In case we want to use a different root type, we'll also hold a reference to the native definition, if one is available. Note that it may be possible to construct instances directly, in which case this would be `null`.
    • _rootType

      protected final ProtobufMessage _rootType
  • Constructor Details

  • Method Details

    • withRootType

      public ProtobufSchema withRootType(String typeName) throws IllegalArgumentException
      Method that can be called to choose different root type (of types defined in protoc); a new schema instance will be constructed if type is different from current root type.

      Note that cost of changing root type is non-trivial in that traversal of types defined is needed -- but exact cost depends on number of types defined. Since schema instances are immutable, it makes sense to try to reuse instances if possible.

      Throws:
      IllegalArgumentException - If no type with specified name is found from within this schema.
    • getSource

      public NativeProtobufSchema getSource()
      Accessor for native representation of the protoc. Mostly useful for debugging; application code should not need to access this representation during normal operation.
    • getRootType

      public ProtobufMessage getRootType()
      Accessor for getting the default ProtobufMessage type that is usually the root type for this schema.
    • getMessageTypes

      public List<String> getMessageTypes()
      Accessor for listing names of all root-level messages defined in the original protoc.
    • getSchemaType

      public String getSchemaType()
      Accessor to get type id for this FormatSchema, used by code Jackson databinding functionality. Not usually needed by application developers.
      Specified by:
      getSchemaType in interface tools.jackson.core.FormatSchema
    • toString

      public String toString()
      Overrides:
      toString in class Object