public abstract class EnumIO<E extends Enum<E>> extends Object implements PolymorphicSchema.Factory
| Modifier and Type | Class and Description |
|---|---|
static class |
EnumIO.ByName<E extends Enum<E>>
Reads the enum by its name.
|
static class |
EnumIO.ByNumber<E extends Enum<E>>
Reads the enum by its number.
|
| Modifier and Type | Field and Description |
|---|---|
Class<E> |
enumClass
The enum class.
|
ArraySchemas.Base |
genericElementSchema |
IdStrategy |
strategy |
| Constructor and Description |
|---|
EnumIO(Class<E> enumClass,
IdStrategy strategy) |
| Modifier and Type | Method and Description |
|---|---|
String |
getAlias(Enum<?> element) |
E |
getByAlias(String alias) |
E |
getByTag(int tag) |
MapSchema.MessageFactory |
getEnumMapFactory()
Returns the factory for an EnumMap (lazy).
|
CollectionSchema.MessageFactory |
getEnumSetFactory()
Returns the factory for an EnumSet (lazy).
|
int |
getTag(Enum<?> element) |
<V> EnumMap<E,V> |
newEnumMap()
Returns an empty
EnumMap. |
EnumSet<E> |
newEnumSet()
Returns an empty
EnumSet. |
PolymorphicSchema |
newSchema(Class<?> typeClass,
IdStrategy strategy,
PolymorphicSchema.Handler handler) |
abstract E |
readFrom(Input input)
Read the enum from the input.
|
static void |
transfer(Pipe pipe,
Input input,
Output output,
int number,
boolean repeated,
IdStrategy strategy)
Transfers the
Enum from the input to the output. |
void |
writeTo(Output output,
int number,
boolean repeated,
Enum<?> e)
Writes the
Enum to the output. |
public final IdStrategy strategy
public final ArraySchemas.Base genericElementSchema
public EnumIO(Class<E> enumClass, IdStrategy strategy)
public void writeTo(Output output, int number, boolean repeated, Enum<?> e) throws IOException
Enum to the output.IOExceptionpublic static void transfer(Pipe pipe, Input input, Output output, int number, boolean repeated, IdStrategy strategy) throws IOException
Enum from the input to the output.IOExceptionpublic PolymorphicSchema newSchema(Class<?> typeClass, IdStrategy strategy, PolymorphicSchema.Handler handler)
newSchema in interface PolymorphicSchema.Factorypublic int getTag(Enum<?> element)
public E getByTag(int tag)
public CollectionSchema.MessageFactory getEnumSetFactory()
public MapSchema.MessageFactory getEnumMapFactory()
public abstract E readFrom(Input input) throws IOException
IOExceptionCopyright © 2009–2017. All rights reserved.