OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

odata message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]

Subject: [OASIS Issue Tracker] (ODATA-819) 10.2.2: Clarify whether enum types allow multiple members with the same value

    [ https://issues.oasis-open.org/browse/ODATA-819?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=59817#comment-59817 ] 

Michael Pizzo commented on ODATA-819:

Python has two enum types; enum, and intenum. In both cases you can define multiple enum members with the same value. The first value has precedence and is what is returned. From https://docs.python.org/3.4/library/enum.html: 
"Given two members A and B with the same value (and A defined first), B is an alias to A. By-value lookup of the value of A and B will return A. By-name lookup of B will also return A" 
There is an @unique attribute you can put on the enum to force all members to have unique values.

In java, enums are classes; you can define constructors for members but there doesn't seem to be a way to apply values.

In C# you can have two members with the same value and they compare as equal. In my test cases on appears to be an alias for the other, but which member was returned in a lookup by name or seemed indeterminant.  For example, foo.A.ToString() may return "B" if Members A and B have the same value.

I think we should probably allow it (though particular services could always be more restrictive), require that (where supported) members with the same underlying value compare equal, and caution that the choice of which value the service returns is indeterminant.  

> 10.2.2: Clarify whether enum types allow multiple members with the same value
> -----------------------------------------------------------------------------
>                 Key: ODATA-819
>                 URL: https://issues.oasis-open.org/browse/ODATA-819
>             Project: OASIS Open Data Protocol (OData) TC
>          Issue Type: Bug
>          Components: OData CSDL
>    Affects Versions: V4.0_ERRATA02
>            Reporter: Ralf Handl
>             Fix For: V4.0_ERRATA03
> CSDL section 10.2.2 only states that the value of the Value attribute is used for sorting.
> It does not state whether values of the Value attribute have to be unique within an enum type, and it also does not state whether equality comparison of members of non-flag enum types is done by name or by value.
> For flag enum types it states that member combination with the same value are equivalent.

This message was sent by Atlassian JIRA

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]