public interface EnumMarshaller<E extends Enum<E>> extends BaseMarshaller<E>
Enum
types. Translates a Java enum into an int
value
that is suitable for serializing with Protobuf. The returned integer value must be one of the values defined in the
.proto schema file. The marshaller implementation must be stateless and thread-safe.Modifier and Type | Method and Description |
---|---|
E |
decode(int enumValue)
Decodes an integer enum value read from a Protobuf encoded stream into a Java enum instance.
|
int |
encode(E e)
Encodes a Java
Enum into its corresponding Protobuf numeric value. |
getJavaClass, getTypeName
E decode(int enumValue)
If the numeric value is not recognized the method must return null
to signal this to the library and allow
the unrecognized data to be preserved. No exception should be thrown in this case.
enumValue
- the Protobuf enum value to decodeEnum
instance if the value is recognized or null
otherwise.int encode(E e) throws IllegalArgumentException
Enum
into its corresponding Protobuf numeric value.e
- an Enum
instanceIllegalArgumentException
- if the given Enum argument is of an unexpected type or its value has no
correspondence to a Protobuf enum value (this is a programming error, not a
schema evolution issue).Copyright © 2019 JBoss, a division of Red Hat. All rights reserved.