Class RuntimeSchema<T>
java.lang.Object
io.protostuff.runtime.RuntimeSchema<T>
- All Implemented Interfaces:
Schema<T>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringfinal RuntimeEnv.Instantiator<T> static final intstatic final intstatic final int -
Constructor Summary
ConstructorsConstructorDescriptionRuntimeSchema(Class<T> typeClass, Collection<Field<T>> fields, RuntimeEnv.Instantiator<T> instantiator) RuntimeSchema(Class<T> typeClass, Collection<Field<T>> fields, Constructor<T> constructor) -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> RuntimeSchema<T> createFrom(Class<T> typeClass) Generates a schema from the given class.static <T> RuntimeSchema<T> createFrom(Class<T> typeClass, IdStrategy strategy) Generates a schema from the given class.static <T> RuntimeSchema<T> createFrom(Class<T> typeClass, String[] exclusions, IdStrategy strategy) Generates a schema from the given class with the exclusion of certain fields.static <T> RuntimeSchema<T> createFrom(Class<T> typeClass, Map<String, String> declaredFields, IdStrategy strategy) Generates a schema from the given class with the declared fields (inclusive) based from the given Map.static <T> RuntimeSchema<T> createFrom(Class<T> typeClass, Set<String> exclusions, IdStrategy strategy) Generates a schema from the given class with the exclusion of certain fields.getFieldByName(String fieldName) getFieldByNumber(int n) intgetFieldName(int number) Gets the field name associated with the number.intgetFieldNumber(String name) Gets the field number associated with the name.Returns the pipe schema linked to this.static <T> Schema<T> Gets the schema that was either registered or lazily initialized at runtime.static <T> Schema<T> getSchema(Class<T> typeClass, IdStrategy strategy) Gets the schema that was either registered or lazily initialized at runtime.booleanisInitialized(T message) Always returns true, everything is optional.static booleanisRegistered(Class<?> typeClass) Returns true if thetypeClasswas not lazily created.static booleanisRegistered(Class<?> typeClass, IdStrategy strategy) Returns true if thetypeClasswas not lazily created.static <T> booleanMaps thebaseClassto a specific non-interface/non-abstracttypeClassand registers it (this must be done on application startup).final voidDeserializes 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.static <T> booleanReturns true if this there is no existing one or the same schema has already been registered (this must be done on application startup).static <T> booleanReturns true if this there is no existing one or the same schema has already been registered (this must be done on application startup).Gets the class of the message.final voidSerializes a message/object to theoutput.
-
Field Details
-
MIN_TAG_VALUE
public static final int MIN_TAG_VALUE- See Also:
-
MAX_TAG_VALUE
public static final int MAX_TAG_VALUE- See Also:
-
ERROR_TAG_VALUE
- See Also:
-
MIN_TAG_FOR_HASH_FIELD_MAP
public static final int MIN_TAG_FOR_HASH_FIELD_MAP- See Also:
-
instantiator
-
-
Constructor Details
-
RuntimeSchema
-
RuntimeSchema
public RuntimeSchema(Class<T> typeClass, Collection<Field<T>> fields, RuntimeEnv.Instantiator<T> instantiator)
-
-
Method Details
-
map
Maps thebaseClassto a specific non-interface/non-abstracttypeClassand registers it (this must be done on application startup).With this approach, there is no overhead of writing the type metadata if a
baseClassfield is serialized.Returns true if the baseClass does not exist.
NOTE: This is only supported when
RuntimeEnv.ID_STRATEGYisDefaultIdStrategy.- Throws:
IllegalArgumentException- if thetypeClassis an interface or an abstract class.
-
register
Returns true if this there is no existing one or the same schema has already been registered (this must be done on application startup).NOTE: This is only supported when
RuntimeEnv.ID_STRATEGYisDefaultIdStrategy. -
register
Returns true if this there is no existing one or the same schema has already been registered (this must be done on application startup).NOTE: This is only supported when
RuntimeEnv.ID_STRATEGYisDefaultIdStrategy. -
isRegistered
Returns true if thetypeClasswas not lazily created.Method overload for backwards compatibility.
-
isRegistered
Returns true if thetypeClasswas not lazily created. -
getSchema
-
getSchema
Gets the schema that was either registered or lazily initialized at runtime. -
createFrom
Generates a schema from the given class.Method overload for backwards compatibility.
-
createFrom
Generates a schema from the given class. -
createFrom
public static <T> RuntimeSchema<T> createFrom(Class<T> typeClass, String[] exclusions, IdStrategy strategy) Generates a schema from the given class with the exclusion of certain fields. -
createFrom
public static <T> RuntimeSchema<T> createFrom(Class<T> typeClass, Set<String> exclusions, IdStrategy strategy) Generates a schema from the given class with the exclusion of certain fields. -
createFrom
public static <T> RuntimeSchema<T> createFrom(Class<T> typeClass, Map<String, String> declaredFields, IdStrategy strategy) Generates a schema from the given class with the declared fields (inclusive) based from the given Map. The value of a the Map's entry will be the name used for the field (which enables aliasing). -
getPipeSchema
Returns the pipe schema linked to this. -
getFieldByNumber
-
getFieldByName
-
getFieldCount
public int getFieldCount() -
getFields
-
typeClass
-
messageName
Description copied from interface:SchemaReturns the simple name of the message tied to this schema. Allows custom schemas to provide a custom name other than typeClass().getSimpleName();- Specified by:
messageNamein interfaceSchema<T>
-
messageFullName
Description copied from interface:SchemaReturns the full name of the message tied to this schema. Allows custom schemas to provide a custom name other than typeClass().getName();- Specified by:
messageFullNamein interfaceSchema<T>
-
getFieldName
Description copied from interface:SchemaGets 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);
- Specified by:
getFieldNamein interfaceSchema<T>
-
getFieldNumber
Description copied from interface:SchemaGets 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);
- Specified by:
getFieldNumberin interfaceSchema<T>
-
mergeFrom
-
writeTo
-
isInitialized
Always returns true, everything is optional.- Specified by:
isInitializedin interfaceSchema<T>
-
newMessage
Description copied from interface:SchemaCreates the message/object tied to this schema.- Specified by:
newMessagein interfaceSchema<T>
-