public class ProtobufSchema extends Object implements com.fasterxml.jackson.core.FormatSchema
FormatSchema
implementation for protobuf, bound to specific root-level
ProtobufMessage
, and useful for reading/writing protobuf content
that encodes instance of that message.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 and Description |
---|
ProtobufSchema(NativeProtobufSchema src,
ProtobufMessage rootType) |
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.
|
public static final String FORMAT_NAME_PROTOBUF
protected final NativeProtobufSchema _source
protected final ProtobufMessage _rootType
public ProtobufSchema(NativeProtobufSchema src, ProtobufMessage rootType)
public ProtobufSchema withRootType(String typeName) throws IllegalArgumentException
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.
IllegalArgumentException
- If no type with specified name is found
from within this schema.public NativeProtobufSchema getSource()
public ProtobufMessage getRootType()
ProtobufMessage
type that
is usually the root type for this schema.public List<String> getMessageTypes()
public String getSchemaType()
FormatSchema
, used by code Jackson
databinding functionality. Not usually needed by application developers.getSchemaType
in interface com.fasterxml.jackson.core.FormatSchema
Copyright © 2017 FasterXML. All rights reserved.