Skip to content

Use choice types for enums rather than extending enums #1312

Description

@hugohills-regnosys

CDM has several usages where enums are extended, however this is not supported in Java (comparisons don't work properly)

enum EntityIdentifierTypeEnum extends PartyIdentifierTypeEnum: 
    REDID 
    CountryCode 
    Other 

enum PartyIdentifierTypeEnum: 
    BIC 
    LEI 
    MIC 

Choice types can be used as an alternative to enum extension

enum EntityIdentifierTypeEnum: <"No longer extends PartyIdentifierTypeEnum">
    REDID 
    CountryCode 
    Other 

enum PartyIdentifierTypeEnum: 
    BIC 
    LEI 
    MIC 

choice PartyOrEntityIdentifierType:
    EntityIdentifierTypeEnum
    PartyIdentifierTypeEnum

Where comparison of choice type to choice options is allowed

func IsBicOrRedId:
    inputs:
        assetIdentifier PartyOrEntityIdentifierType (0..1)
    output:
        result boolean (0..1)

    set result:
        assetIdentifier = PartyIdentifierTypeEnum -> BIC or assetIdentifier = EntityIdentifierTypeEnum -> REDID
  • Comparison of choice type to choice options should be allowed for types (not just enums)
  • Make the usage of enum extended a warning, and in future an error

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions