Class RuntimeSchema<T>
java.lang.Object
io.protostuff.runtime.RuntimeSchema<T>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringfinal RuntimeEnv.Instantiator<T> static final intstatic final intstatic final intprivate final Pipe.Schema<T> -
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 TypeMethodDescriptioncreateFieldMap(Collection<Field<T>> fields) static <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.(package private) static voidfindInstanceFields(Class<?> typeClass) 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.(package private) static <T> HasSchema<T> getSchemaWrapper(Class<T> typeClass) Returns the schema wrapper.(package private) static <T> HasSchema<T> getSchemaWrapper(Class<T> typeClass, IdStrategy strategy) Returns the schema wrapper.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.private booleanpreferHashFieldMap(Collection<Field<T>> fields, int lastFieldNumber) 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).(package private) static <T> Pipe.Schema<T> resolvePipeSchema(Schema<T> schema, Class<? super T> clazz, boolean throwIfNone) Invoked only when applications are having pipe io operations.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:
-
NO_EXCLUSIONS
-
MIN_TAG_FOR_HASH_FIELD_MAP
public static final int MIN_TAG_FOR_HASH_FIELD_MAP- See Also:
-
pipeSchema
-
fieldMap
-
typeClass
-
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. -
getSchemaWrapper
-
getSchemaWrapper
Returns the schema wrapper. -
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). -
findInstanceFields
-
fill
-
createFieldMap
-
preferHashFieldMap
-
getPipeSchema
Returns the pipe schema linked to this. -
getFieldByNumber
- Specified by:
getFieldByNumberin interfaceFieldMap<T>
-
getFieldByName
-
getFieldCount
public int getFieldCount()- Specified by:
getFieldCountin interfaceFieldMap<T>
-
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>
-
resolvePipeSchema
static <T> Pipe.Schema<T> resolvePipeSchema(Schema<T> schema, Class<? super T> clazz, boolean throwIfNone) Invoked only when applications are having pipe io operations.
-