Skip to content

[java] adding values in enum in a new template version #411

Closed
@avaiss

Description

@avaiss

If a SBE template new version updates an enum by adding a value to it ; then the generated code for the previous version will throw an exception when trying to decode the enum.

For example:

 public static BlockTradeCode_enum get(final byte value)
    {
        switch (value)
        {
            case 66: return Block_Trade;
            case 78: return Regular_trade_or_Negotiated_deal;
            case 45: return Undefined;
        }

        if ((byte)0 == value)
        {
            return NULL_VAL;
        }

        throw new IllegalArgumentException("Unknown value: " + value);
    }

Is this by design ?

An alternative would be to add the UNKNOWN value for the enum and return it instead of throwing, so existing code won't break in that case.

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