Skip to content

Value of NULL_VAL generated for enums is not the nullValue specified for encodingType but the null value for the primitive type #889

Closed
@EEWatanabe

Description

@EEWatanabe

The value of NULL_VAL generated for enums is not the nullValue specified for encodingType but the null value for the primitive type.
(Testing with version 1.25.1)
For instance:

// SBE Template definition
		<type name="uInt8NULL" primitiveType="uint8" presence="optional" nullValue="0" description="1-byte unsigned integer, from 1 to 255, NULL (optional) value = 0" />
...
		<enum name="LotType" encodingType="uInt8NULL" semanticType="Int" description="Describes the lot type for the instruments. Used for the Equities segment.">
			<validValue name="ODD_LOT" description="Odd lot">1</validValue>
			<validValue name="ROUND_LOT" description="Round lot">2</validValue>
			<validValue name="BLOCK_LOT" description="Block lot">3</validValue>
		</enum>
// Generated code (Java)
public enum LotType
...
    /**
     * To be used to represent not present or null.
     */
    NULL_VAL((short)255);

I expect NULL_VAL to be ((short) 0).

I can't just specify 'NULL_VAL' as a <validValue> because it creates an invalid Java file (with 2 constants NULL_VAL with the same name).

By printing the intermediate representation for the enum, we can see that the enum behaves like the encoding is always required, and uses the default value for nullValue, that's 255 in this case.

  Token{signal=BEGIN_ENUM, name='LotType', referencedName='null', description='Describes the lot type for the instruments. Used for the Equities segment.', id=-1, version=0, deprecated=0, encodedLength=1, offset=198, componentTokenCount=5, encoding=Encoding{presence=REQUIRED, primitiveType=UINT8, byteOrder=LITTLE_ENDIAN, minValue=null, maxValue=null, nullValue=255, constValue=null, characterEncoding='null', epoch='null', timeUnit=null, semanticType='Int'}}
  Token{signal=VALID_VALUE, name='ODD_LOT', referencedName='null', description='Odd lot', id=-1, version=0, deprecated=0, encodedLength=0, offset=0, componentTokenCount=1, encoding=Encoding{presence=REQUIRED, primitiveType=UINT8, byteOrder=LITTLE_ENDIAN, minValue=null, maxValue=null, nullValue=null, constValue=1, characterEncoding='null', epoch='null', timeUnit=null, semanticType='null'}}
  Token{signal=VALID_VALUE, name='ROUND_LOT', referencedName='null', description='Round lot', id=-1, version=0, deprecated=0, encodedLength=0, offset=0, componentTokenCount=1, encoding=Encoding{presence=REQUIRED, primitiveType=UINT8, byteOrder=LITTLE_ENDIAN, minValue=null, maxValue=null, nullValue=null, constValue=2, characterEncoding='null', epoch='null', timeUnit=null, semanticType='null'}}
  Token{signal=VALID_VALUE, name='BLOCK_LOT', referencedName='null', description='Block lot', id=-1, version=0, deprecated=0, encodedLength=0, offset=0, componentTokenCount=1, encoding=Encoding{presence=REQUIRED, primitiveType=UINT8, byteOrder=LITTLE_ENDIAN, minValue=null, maxValue=null, nullValue=null, constValue=3, characterEncoding='null', epoch='null', timeUnit=null, semanticType='null'}}
  Token{signal=END_ENUM, name='LotType', referencedName='null', description='Describes the lot type for the instruments. Used for the Equities segment.', id=-1, version=0, deprecated=0, encodedLength=1, offset=198, componentTokenCount=5, encoding=Encoding{presence=REQUIRED, primitiveType=UINT8, byteOrder=LITTLE_ENDIAN, minValue=null, maxValue=null, nullValue=255, constValue=null, characterEncoding='null', epoch='null', timeUnit=null, semanticType='Int'}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions