Class ExplicitIdStrategy
java.lang.Object
io.protostuff.runtime.IdStrategy
io.protostuff.runtime.NumericIdStrategy
io.protostuff.runtime.ExplicitIdStrategy
Requires every messsage/pojo/enum/collection/map to be registered with unique ids.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class(package private) static final class(package private) static final class(package private) static final class(package private) static final class(package private) static final classstatic classThis Registry is only way to register your pojos/enums/collections/maps/delegates.Nested classes/interfaces inherited from class NumericIdStrategy
NumericIdStrategy.RegisteredDelegate<T>Nested classes/interfaces inherited from class IdStrategy
IdStrategy.Factory, IdStrategy.UnknownTypeException, IdStrategy.Wrapper -
Field Summary
FieldsModifier and TypeFieldDescription(package private) final IdentityHashMap<Class<?>, ExplicitIdStrategy.RegisteredCollectionFactory> (package private) final ArrayList<ExplicitIdStrategy.RegisteredCollectionFactory> (package private) final IdentityHashMap<Class<?>, NumericIdStrategy.RegisteredDelegate<?>> (package private) final ArrayList<NumericIdStrategy.RegisteredDelegate<?>> (package private) final IdentityHashMap<Class<?>, ExplicitIdStrategy.RegisteredEnumIO> (package private) final ArrayList<ExplicitIdStrategy.RegisteredEnumIO> (package private) final IdentityHashMap<Class<?>, ExplicitIdStrategy.RegisteredMapFactory> (package private) final ArrayList<ExplicitIdStrategy.RegisteredMapFactory> (package private) final IdentityHashMap<Class<?>, ExplicitIdStrategy.BaseHS<?>> (package private) final ArrayList<ExplicitIdStrategy.BaseHS<?>> Fields inherited from class NumericIdStrategy
CID_BIGDECIMAL, CID_BIGINTEGER, CID_BOOL, CID_BYTE, CID_BYTE_ARRAY, CID_BYTES, CID_CHAR, CID_CLASS, CID_COLLECTION, CID_DATE, CID_DELEGATE, CID_DOUBLE, CID_ENUM, CID_ENUM_MAP, CID_ENUM_SET, CID_FLOAT, CID_INT32, CID_INT64, CID_MAP, CID_OBJECT, CID_POJO, CID_SHORT, CID_STRINGFields inherited from class IdStrategy
ARRAY_BIGDECIMAL_SCHEMA, ARRAY_BIGINTEGER_SCHEMA, ARRAY_BOOL_BOXED_SCHEMA, ARRAY_BOOL_DERIVED_SCHEMA, ARRAY_BOOL_PRIMITIVE_SCHEMA, ARRAY_BYTEARRAY_SCHEMA, ARRAY_BYTESTRING_SCHEMA, ARRAY_CHAR_BOXED_SCHEMA, ARRAY_CHAR_DERIVED_SCHEMA, ARRAY_CHAR_PRIMITIVE_SCHEMA, ARRAY_DATE_SCHEMA, ARRAY_DOUBLE_BOXED_SCHEMA, ARRAY_DOUBLE_DERIVED_SCHEMA, ARRAY_DOUBLE_PRIMITIVE_SCHEMA, ARRAY_ELEMENT_SCHEMA, ARRAY_FLOAT_BOXED_SCHEMA, ARRAY_FLOAT_DERIVED_SCHEMA, ARRAY_FLOAT_PRIMITIVE_SCHEMA, ARRAY_INT32_BOXED_SCHEMA, ARRAY_INT32_DERIVED_SCHEMA, ARRAY_INT32_PRIMITIVE_SCHEMA, ARRAY_INT64_BOXED_SCHEMA, ARRAY_INT64_DERIVED_SCHEMA, ARRAY_INT64_PRIMITIVE_SCHEMA, ARRAY_PIPE_SCHEMA, ARRAY_SCHEMA, ARRAY_SHORT_BOXED_SCHEMA, ARRAY_SHORT_DERIVED_SCHEMA, ARRAY_SHORT_PRIMITIVE_SCHEMA, ARRAY_STRING_SCHEMA, AUTO_LOAD_POLYMORPHIC_CLASSES, CLASS_ELEMENT_SCHEMA, CLASS_PIPE_SCHEMA, CLASS_SCHEMA, COLLECTION_PIPE_SCHEMA, COLLECTION_SCHEMA, COLLECTION_SCHEMA_ON_REPEATED_FIELDS, DEFAULT_FLAGS, DYNAMIC_VALUE_PIPE_SCHEMA, DYNAMIC_VALUE_SCHEMA, ENTRY_PIPE_SCHEMA, ENTRY_SCHEMA, ENUMS_BY_NAME, flags, groupId, MAP_PIPE_SCHEMA, MAP_SCHEMA, MORPH_COLLECTION_INTERFACES, MORPH_MAP_INTERFACES, MORPH_NON_FINAL_POJOS, NUMBER_ELEMENT_SCHEMA, OBJECT_ELEMENT_SCHEMA, OBJECT_PIPE_SCHEMA, OBJECT_SCHEMA, POJO_SCHEMA_ON_COLLECTION_FIELDS, POJO_SCHEMA_ON_MAP_FIELDS, POLYMORPHIC_COLLECTION_PIPE_SCHEMA, POLYMORPHIC_COLLECTION_SCHEMA, POLYMORPHIC_ENUM_ELEMENT_SCHEMA, POLYMORPHIC_MAP_PIPE_SCHEMA, POLYMORPHIC_MAP_SCHEMA, POLYMORPHIC_POJO_ELEMENT_SCHEMA, POLYMORPHIC_THROWABLE_ELEMENT_SCHEMA, PRESERVE_NULL_ELEMENTS, preserveNull, primaryGroup -
Constructor Summary
ConstructorsConstructorDescriptionExplicitIdStrategy(int flags, IdStrategy primaryGroup, int groupId, IdentityHashMap<Class<?>, ExplicitIdStrategy.RegisteredCollectionFactory> collectionMapping, ArrayList<ExplicitIdStrategy.RegisteredCollectionFactory> collections, IdentityHashMap<Class<?>, ExplicitIdStrategy.RegisteredMapFactory> mapMapping, ArrayList<ExplicitIdStrategy.RegisteredMapFactory> maps, IdentityHashMap<Class<?>, ExplicitIdStrategy.RegisteredEnumIO> enumMapping, ArrayList<ExplicitIdStrategy.RegisteredEnumIO> enums, IdentityHashMap<Class<?>, ExplicitIdStrategy.BaseHS<?>> pojoMapping, ArrayList<ExplicitIdStrategy.BaseHS<?>> pojos, IdentityHashMap<Class<?>, NumericIdStrategy.RegisteredDelegate<?>> delegateMapping, ArrayList<NumericIdStrategy.RegisteredDelegate<?>> delegates) ExplicitIdStrategy(IdentityHashMap<Class<?>, ExplicitIdStrategy.RegisteredCollectionFactory> collectionMapping, ArrayList<ExplicitIdStrategy.RegisteredCollectionFactory> collections, IdentityHashMap<Class<?>, ExplicitIdStrategy.RegisteredMapFactory> mapMapping, ArrayList<ExplicitIdStrategy.RegisteredMapFactory> maps, IdentityHashMap<Class<?>, ExplicitIdStrategy.RegisteredEnumIO> enumMapping, ArrayList<ExplicitIdStrategy.RegisteredEnumIO> enums, IdentityHashMap<Class<?>, ExplicitIdStrategy.BaseHS<?>> pojoMapping, ArrayList<ExplicitIdStrategy.BaseHS<?>> pojos, IdentityHashMap<Class<?>, NumericIdStrategy.RegisteredDelegate<?>> delegateMapping, ArrayList<NumericIdStrategy.RegisteredDelegate<?>> delegates) -
Method Summary
Modifier and TypeMethodDescriptionprotected Class<?> collectionClass(int id) private intcollectionId(Class<?> clazz) protected Class<?> delegateClass(int id) protected Class<?> enumClass(int id) protected CollectionSchema.MessageFactorygetCollectionFactory(Class<?> clazz) Returns theCollectionSchema.MessageFactory.<T> Delegate<T> getDelegate(Class<? super T> typeClass) Returns thedelegate.<T> HasDelegate<T> getDelegateWrapper(Class<? super T> typeClass) Returns thedelegate.protected intReturns theEnumIO.protected intprotected MapSchema.MessageFactorygetMapFactory(Class<?> clazz) Returns theMapSchema.MessageFactory.protected NumericIdStrategy.RegisteredDelegate<?> getRegisteredDelegate(Class<?> clazz) <T> HasSchema<T> getSchemaWrapper(Class<T> typeClass, boolean create) Returns theschema wrapper.booleanisDelegateRegistered(Class<?> typeClass) Returns true if there is aDelegateexplicitly registered for thetypeClass.booleanisRegistered(Class<?> typeClass) Returns true if thetypeClassis explicitly registered.protected Class<?> mapClass(int id) private int(package private) static <K,V> IdentityHashMap <K, V> newMap(int size) protected Class<?> pojoClass(int id) protected CollectionSchema.MessageFactoryresolveCollectionFrom(Input input) protected <T> HasDelegate<T> resolveDelegateFrom(Input input) protected EnumIO<?> resolveEnumFrom(Input input) protected MapSchema.MessageFactoryresolveMapFrom(Input input) protected <T> HasSchema<T> resolvePojoFrom(Input input, int fieldNumber) protected voidtransferCollectionId(Input input, Output output, int fieldNumber) protected <T> HasDelegate<T> transferDelegateId(Input input, Output output, int fieldNumber) protected voidtransferEnumId(Input input, Output output, int fieldNumber) protected voidtransferMapId(Input input, Output output, int fieldNumber) protected <T> HasSchema<T> transferPojoId(Input input, Output output, int fieldNumber) protected <T> HasDelegate<T> tryWriteDelegateIdTo(Output output, int fieldNumber, Class<T> clazz) If this method returns null, the clazz was not registered as a delegate.protected <T> HasSchema<T> tryWritePojoIdTo(Output output, int fieldNumber, Class<T> clazz, boolean registered) protected voidwriteCollectionIdTo(Output output, int fieldNumber, Class<?> clazz) protected voidwriteEnumIdTo(Output output, int fieldNumber, Class<?> clazz) protected voidwriteMapIdTo(Output output, int fieldNumber, Class<?> clazz) protected <T> Schema<T> writeMessageIdTo(Output output, int fieldNumber, Message<T> message) protected <T> HasSchema<T> writePojoIdTo(Output output, int fieldNumber, Class<T> clazz) Methods inherited from class NumericIdStrategy
grow, newList, resolveArrayComponentTypeFrom, resolveClassFrom, transferArrayId, transferClassId, writeArrayIdTo, writeClassIdToMethods inherited from class IdStrategy
createMessageInstance, newSchema
-
Field Details
-
collectionMapping
-
collections
-
mapMapping
-
maps
-
enumMapping
-
enums
-
pojoMapping
-
pojos
-
delegateMapping
-
delegates
-
-
Constructor Details
-
ExplicitIdStrategy
public ExplicitIdStrategy(IdentityHashMap<Class<?>, ExplicitIdStrategy.RegisteredCollectionFactory> collectionMapping, ArrayList<ExplicitIdStrategy.RegisteredCollectionFactory> collections, IdentityHashMap<Class<?>, ExplicitIdStrategy.RegisteredMapFactory> mapMapping, ArrayList<ExplicitIdStrategy.RegisteredMapFactory> maps, IdentityHashMap<Class<?>, ExplicitIdStrategy.RegisteredEnumIO> enumMapping, ArrayList<ExplicitIdStrategy.RegisteredEnumIO> enums, IdentityHashMap<Class<?>, ExplicitIdStrategy.BaseHS<?>> pojoMapping, ArrayList<ExplicitIdStrategy.BaseHS<?>> pojos, IdentityHashMap<Class<?>, NumericIdStrategy.RegisteredDelegate<?>> delegateMapping, ArrayList<NumericIdStrategy.RegisteredDelegate<?>> delegates) -
ExplicitIdStrategy
public ExplicitIdStrategy(int flags, IdStrategy primaryGroup, int groupId, IdentityHashMap<Class<?>, ExplicitIdStrategy.RegisteredCollectionFactory> collectionMapping, ArrayList<ExplicitIdStrategy.RegisteredCollectionFactory> collections, IdentityHashMap<Class<?>, ExplicitIdStrategy.RegisteredMapFactory> mapMapping, ArrayList<ExplicitIdStrategy.RegisteredMapFactory> maps, IdentityHashMap<Class<?>, ExplicitIdStrategy.RegisteredEnumIO> enumMapping, ArrayList<ExplicitIdStrategy.RegisteredEnumIO> enums, IdentityHashMap<Class<?>, ExplicitIdStrategy.BaseHS<?>> pojoMapping, ArrayList<ExplicitIdStrategy.BaseHS<?>> pojos, IdentityHashMap<Class<?>, NumericIdStrategy.RegisteredDelegate<?>> delegateMapping, ArrayList<NumericIdStrategy.RegisteredDelegate<?>> delegates)
-
-
Method Details
-
isRegistered
Description copied from class:IdStrategyReturns true if thetypeClassis explicitly registered.- Specified by:
isRegisteredin classIdStrategy
-
getSchemaWrapper
Description copied from class:IdStrategyReturns theschema wrapper. The caller is responsible that the typeClass is a pojo (e.g not an enum/array/etc).- Specified by:
getSchemaWrapperin classIdStrategy
-
getEnumIO
Description copied from class:IdStrategyReturns theEnumIO. The callers (internal field factories) are responsible that the class provided is an enum class.- Specified by:
getEnumIOin classIdStrategy
-
getCollectionFactory
Description copied from class:IdStrategyReturns theCollectionSchema.MessageFactory. The callers (internal field factories) are responsible that the class provided implementsCollection.- Specified by:
getCollectionFactoryin classIdStrategy
-
getMapFactory
Description copied from class:IdStrategyReturns theMapSchema.MessageFactory. The callers (internal field factories}) are responsible that the class provided implementsMap.- Specified by:
getMapFactoryin classIdStrategy
-
writeCollectionIdTo
protected void writeCollectionIdTo(Output output, int fieldNumber, Class<?> clazz) throws IOException - Specified by:
writeCollectionIdToin classIdStrategy- Throws:
IOException
-
transferCollectionId
- Specified by:
transferCollectionIdin classIdStrategy- Throws:
IOException
-
resolveCollectionFrom
- Specified by:
resolveCollectionFromin classIdStrategy- Throws:
IOException
-
writeMapIdTo
- Specified by:
writeMapIdToin classIdStrategy- Throws:
IOException
-
transferMapId
- Specified by:
transferMapIdin classIdStrategy- Throws:
IOException
-
resolveMapFrom
- Specified by:
resolveMapFromin classIdStrategy- Throws:
IOException
-
writeEnumIdTo
- Specified by:
writeEnumIdToin classIdStrategy- Throws:
IOException
-
transferEnumId
- Specified by:
transferEnumIdin classIdStrategy- Throws:
IOException
-
resolveEnumFrom
- Specified by:
resolveEnumFromin classIdStrategy- Throws:
IOException
-
isDelegateRegistered
Description copied from class:IdStrategyReturns true if there is aDelegateexplicitly registered for thetypeClass.- Specified by:
isDelegateRegisteredin classIdStrategy
-
getDelegate
Description copied from class:IdStrategyReturns thedelegate.- Specified by:
getDelegatein classIdStrategy
-
getDelegateWrapper
Description copied from class:IdStrategyReturns thedelegate.- Specified by:
getDelegateWrapperin classIdStrategy
-
tryWriteDelegateIdTo
protected <T> HasDelegate<T> tryWriteDelegateIdTo(Output output, int fieldNumber, Class<T> clazz) throws IOException Description copied from class:IdStrategyIf this method returns null, the clazz was not registered as a delegate.- Specified by:
tryWriteDelegateIdToin classIdStrategy- Throws:
IOException
-
transferDelegateId
protected <T> HasDelegate<T> transferDelegateId(Input input, Output output, int fieldNumber) throws IOException - Specified by:
transferDelegateIdin classIdStrategy- Throws:
IOException
-
resolveDelegateFrom
- Specified by:
resolveDelegateFromin classIdStrategy- Throws:
IOException
-
tryWritePojoIdTo
protected <T> HasSchema<T> tryWritePojoIdTo(Output output, int fieldNumber, Class<T> clazz, boolean registered) throws IOException - Specified by:
tryWritePojoIdToin classIdStrategy- Throws:
IOException
-
writePojoIdTo
protected <T> HasSchema<T> writePojoIdTo(Output output, int fieldNumber, Class<T> clazz) throws IOException - Specified by:
writePojoIdToin classIdStrategy- Throws:
IOException
-
transferPojoId
protected <T> HasSchema<T> transferPojoId(Input input, Output output, int fieldNumber) throws IOException - Specified by:
transferPojoIdin classIdStrategy- Throws:
IOException
-
resolvePojoFrom
- Specified by:
resolvePojoFromin classIdStrategy- Throws:
IOException
-
writeMessageIdTo
protected <T> Schema<T> writeMessageIdTo(Output output, int fieldNumber, Message<T> message) throws IOException - Specified by:
writeMessageIdToin classIdStrategy- Throws:
IOException
-
collectionClass
- Specified by:
collectionClassin classNumericIdStrategy
-
mapClass
- Specified by:
mapClassin classNumericIdStrategy
-
enumClass
- Specified by:
enumClassin classNumericIdStrategy
-
delegateClass
- Specified by:
delegateClassin classNumericIdStrategy
-
pojoClass
- Specified by:
pojoClassin classNumericIdStrategy
-
getRegisteredDelegate
- Specified by:
getRegisteredDelegatein classNumericIdStrategy
-
getEnumId
- Specified by:
getEnumIdin classNumericIdStrategy
-
getId
- Specified by:
getIdin classNumericIdStrategy
-
collectionId
-
mapId
-
newMap
-