Package org.infinispan.protostream
Interface EnumMarshaller<E extends Enum<E>>
-
- All Superinterfaces:
BaseMarshaller<E>
public interface EnumMarshaller<E extends Enum<E>> extends BaseMarshaller<E>
Contract to be implemented by marshallers ofEnumtypes. Translates a Java enum into anintvalue 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.- Since:
- 1.0
- Author:
- anistor@redhat.com
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Edecode(int enumValue)Decodes an integer enum value read from a Protobuf encoded stream into a Java enum instance.intencode(E e)Encodes a JavaEnuminto its corresponding Protobuf numeric value.-
Methods inherited from interface org.infinispan.protostream.BaseMarshaller
getJavaClass, getTypeName
-
-
-
-
Method Detail
-
decode
E decode(int enumValue)
Decodes an integer enum value read from a Protobuf encoded stream into a Java enum instance.If the numeric value is not recognized the method must return
nullto signal this to the library and allow the unrecognized data to be preserved. No exception should be thrown in this case.- Parameters:
enumValue- the Protobuf enum value to decode- Returns:
- a Java
Enuminstance if the value is recognized ornullotherwise.
-
encode
int encode(E e) throws IllegalArgumentException
Encodes a JavaEnuminto its corresponding Protobuf numeric value.- Parameters:
e- anEnuminstance- Returns:
- the corresponding numeric value from the Protobuf definition of the enum.
- Throws:
IllegalArgumentException- 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).
-
-