Class EnumIO<E extends Enum<E>>
java.lang.Object
io.protostuff.runtime.EnumIO<E>
- All Implemented Interfaces:
PolymorphicSchema.Factory
- Direct Known Subclasses:
EnumIO.ByName, EnumIO.ByNumber
Determines how enums are serialized/deserialized. Default is BY_NUMBER. To enable BY_NAME, set the property
"protostuff.runtime.enums_by_name=true".
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classEnumIO.ByName<E extends Enum<E>>Reads the enum by its name.static final classEnumIO.ByNumber<E extends Enum<E>>Reads the enum by its number. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Fieldprivate static final Fieldprivate final String[]The enum class.private MapSchema.MessageFactoryprivate CollectionSchema.MessageFactoryfinal ArraySchemas.Basefinal IdStrategyprivate final int[] -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetByAlias(String alias) getByTag(int tag) (package private) static Class<?> getElementTypeFromEnumSet(Object enumSet) Retrieves the enum key type from the EnumMap via reflection.Returns the factory for an EnumMap (lazy).Returns the factory for an EnumSet (lazy).(package private) static Class<?> getKeyTypeFromEnumMap(Object enumMap) Retrieves the enum key type from the EnumMap via reflection.intnewEnumIO(Class<?> enumClass, IdStrategy strategy) Returns an emptyEnumMap.private static <E extends Enum<E>>
MapSchema.MessageFactorynewEnumMapFactory(EnumIO<E> eio) Returns an emptyEnumSet.private static <E extends Enum<E>>
CollectionSchema.MessageFactorynewEnumSetFactory(EnumIO<E> eio) newSchema(Class<?> typeClass, IdStrategy strategy, PolymorphicSchema.Handler handler) abstract ERead the enum from the input.static voidtransfer(Pipe pipe, Input input, Output output, int number, boolean repeated, IdStrategy strategy) Transfers theEnumfrom the input to the output.voidWrites theEnumto the output.
-
Field Details
-
__keyTypeFromEnumMap
-
__elementTypeFromEnumSet
-
enumClass
-
strategy
-
genericElementSchema
-
enumSetFactory
-
enumMapFactory
-
alias
-
tag
private final int[] tag -
valueByAliasMap
-
valueByTagMap
-
-
Constructor Details
-
EnumIO
-
-
Method Details
-
getKeyTypeFromEnumMap
Retrieves the enum key type from the EnumMap via reflection. This is used byObjectSchema. -
getElementTypeFromEnumSet
Retrieves the enum key type from the EnumMap via reflection. This is used byObjectSchema. -
newEnumIO
-
writeTo
Writes theEnumto the output.- Throws:
IOException
-
transfer
public static void transfer(Pipe pipe, Input input, Output output, int number, boolean repeated, IdStrategy strategy) throws IOException Transfers theEnumfrom the input to the output.- Throws:
IOException
-
newEnumSetFactory
-
newEnumMapFactory
-
newSchema
public PolymorphicSchema newSchema(Class<?> typeClass, IdStrategy strategy, PolymorphicSchema.Handler handler) - Specified by:
newSchemain interfacePolymorphicSchema.Factory
-
getTag
-
getAlias
-
getByTag
-
getByAlias
-
getEnumSetFactory
Returns the factory for an EnumSet (lazy). -
getEnumMapFactory
Returns the factory for an EnumMap (lazy). -
newEnumSet
-
newEnumMap
-
readFrom
Read the enum from the input.- Throws:
IOException
-