Class EnumType

  • All Implemented Interfaces:
    java.lang.Comparable<DataType>

    public final class EnumType
    extends DataType
    Provides binary serialization/de-serialization of java.lang.Enum instances.
    Author:
    Charles Rapp
    • Field Detail

      • BYTES

        public static final int BYTES
        An enum requires 2 bytes for encoding.
        See Also:
        Constant Field Values
    • Method Detail

      • isInstance

        public boolean isInstance​(java.lang.Object o)
        Returns true if o is a non-null enum instance and false otherwise.
        Overrides:
        isInstance in class DataType
        Parameters:
        o - Check this object's type.
        Returns:
        true if o is a non-null enum instance and false otherwise.
      • createSerializer

        protected void createSerializer​(MessageType.MessageField field,
                                        java.lang.String fieldName,
                                        java.lang.String indent,
                                        java.util.Formatter output)
        Adds the Java code used to serialize the enum ordinal value to a ByteBuffer.
        Specified by:
        createSerializer in class DataType
        Parameters:
        field - message field.
        fieldName - the message field name.
        indent - indent the code by this amount.
        output - write the code to this formatter.
      • createDeserializer

        protected void createDeserializer​(MessageType.MessageField field,
                                          java.lang.String fieldName,
                                          java.lang.String indent,
                                          java.util.Formatter output,
                                          boolean useBuilder)
        Generates the code to de-serialize the enum instance from a ByteBuffer based on the enum ordinal value.
        Specified by:
        createDeserializer in class DataType
        Parameters:
        field - message field.
        fieldName - store the de-serialized field in this name.
        indent - indent the code by this amount.
        output - append the code to this formatter.
        useBuilder - if true then fieldName is a builder method name; otherwise a local variable.