Package io.protostuff
Interface Schema<T>
- All Known Implementing Classes:
ArraySchema
,ArraySchemas.Base
,ArraySchemas.BigDecimalArray
,ArraySchemas.BigIntegerArray
,ArraySchemas.BoolArray
,ArraySchemas.ByteArrayArray
,ArraySchemas.ByteStringArray
,ArraySchemas.CharArray
,ArraySchemas.DateArray
,ArraySchemas.DelegateArray
,ArraySchemas.DoubleArray
,ArraySchemas.EnumArray
,ArraySchemas.FloatArray
,ArraySchemas.Int32Array
,ArraySchemas.Int64Array
,ArraySchemas.PojoArray
,ArraySchemas.ShortArray
,ArraySchemas.StringArray
,ClassSchema
,CollectionSchema
,CustomSchema
,DerivativeSchema
,GraphByteArrayInput
,GraphCodedInput
,MapSchema
,MessageCollectionSchema
,MessageMapSchema
,NumberSchema
,ObjectSchema
,Pipe.Schema
,PolymorphicCollectionSchema
,PolymorphicEnumSchema
,PolymorphicMapSchema
,PolymorphicPojoCollectionSchema
,PolymorphicPojoMapSchema
,PolymorphicPojoSchema
,PolymorphicSchema
,PolymorphicThrowableSchema
,RuntimePipeSchema
,RuntimeSchema
,RuntimeView.BaseSchema
,RuntimeView.PostFilteredSchema
,StringMapSchema
public interface Schema<T>
Handles the serialization and deserialization of a message/object tied to this.
Basically, any object can be serialized via protobuf. As long as its schema is provided, it does not need to
implement Message
. This was designed with "unobtrusive" in mind. The goal was to be able to
serialize/deserialize any existing object without having to touch its source. This will enable you to customize the
serialization of objects from 3rd party libraries.
-
Method Summary
Modifier and TypeMethodDescriptiongetFieldName
(int number) Gets the field name associated with the number.int
getFieldNumber
(String name) Gets the field number associated with the name.boolean
isInitialized
(T message) Returns true if there is no required field or if all the required fields are set.void
Deserializes a message/object from theinput
.Returns the full name of the message tied to this schema.Returns the simple name of the message tied to this schema.Creates the message/object tied to this schema.Gets the class of the message.void
Serializes a message/object to theoutput
.
-
Method Details
-
getFieldName
Gets the field name associated with the number. This is particularly useful when serializing to different formats (Eg. JSON). When using numeric field names:return String.valueOf(number);
-
getFieldNumber
Gets the field number associated with the name. This is particularly useful when serializing to different formats (Eg. JSON). When using numeric field names:return Integer.parseInt(name);
-
isInitialized
Returns true if there is no required field or if all the required fields are set. -
newMessage
T newMessage()Creates the message/object tied to this schema. -
messageName
String messageName()Returns the simple name of the message tied to this schema. Allows custom schemas to provide a custom name other than typeClass().getSimpleName(); -
messageFullName
String messageFullName()Returns the full name of the message tied to this schema. Allows custom schemas to provide a custom name other than typeClass().getName(); -
typeClass
Gets the class of the message. -
mergeFrom
Deserializes a message/object from theinput
.- Throws:
IOException
-
writeTo
Serializes a message/object to theoutput
.- Throws:
IOException
-