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".
- Author:
- David Yu
-
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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetByAlias(String alias) getByTag(int tag) Returns the factory for an EnumMap (lazy).Returns the factory for an EnumSet (lazy).intReturns an emptyEnumMap.Returns an emptyEnumSet.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
-
enumClass
-
strategy
-
genericElementSchema
-
-
Constructor Details
-
EnumIO
-
-
Method Details
-
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
-
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
-