cancel
Showing results for 
Search instead for 
Did you mean: 

Enumeration with code="1"

0 Kudos
294

Hi

i want to create a enum as below but build and eclipse also show i cannot create enum like this with error "cvc-attribute.3: The value '1' of attribute 'code' on element 'value' is not valid with respect to its type, 'enumCodeType'." how to achieve this?

 <enumtype code="LocalityType" autocreate="true" generate="true">
            <value code="1"/>
            <value code="2"/>
            <value code="3"/>
            <value code="4"/>
        </enumtype>

View Entire Topic
StefanKruk
Active Participant

Enums in Java cannot be numbers. You need to name them like this

 <enumtype code="LocalityType" autocreate="true" generate="true">
            <value code="ONE"/>
            <value code="TWO"/>
            <value code="THREE"/>
            <value code="FOUR"/>
        </enumtype>

As it is an Enum you can then use the ordinal that is specifying the Position.