com.fasterxml.jackson.dataformat.protobuf.schema

## Class ProtobufSchema

- java.lang.Object
- - com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchema

- All Implemented Interfaces:
    com.fasterxml.jackson.core.FormatSchema

      public class ProtobufSchema
      extends Object
      implements com.fasterxml.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 Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected ProtobufMessage` | `_rootType`
    `protected 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.
    `static String` | `FORMAT_NAME_PROTOBUF`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ProtobufSchema(NativeProtobufSchema src, ProtobufMessage rootType)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `List<String>` | `getMessageTypes()` Accessor for listing names of all root-level messages defined in the original protoc.
    `ProtobufMessage` | `getRootType()` Accessor for getting the default `ProtobufMessage` type that is usually the root type for this schema.
    `String` | `getSchemaType()` Accessor to get type id for this `FormatSchema`, used by code Jackson databinding functionality.
    `NativeProtobufSchema` | `getSource()` Accessor for native representation of the protoc.
    `String` | `toString()`
    `ProtobufSchema` | `withRootType(String typeName)` 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.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### FORMAT_NAME_PROTOBUF

          public static final String FORMAT_NAME_PROTOBUF

      See Also:
        Constant Field Values

    - #### _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 Detail

    - #### ProtobufSchema

          public ProtobufSchema(NativeProtobufSchema src,
                        ProtobufMessage rootType)

  - ### Method Detail

    - #### 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 `com.fasterxml.jackson.core.FormatSchema`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2017 FasterXML. All rights reserved.