-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for merged enum #525
Comments
As part of this issue, we would also like the DSL to support asserting whether the value of a merged enum belongs to one or the other base enum - i.e. whether a rate option is a floating rate option or an inflation rate option in our use case - without having to assert against each possible value. |
In a way, I think this may be partially supported already. This could be modelled with an empty super enum:
... from which
A
There is a related issue that might sometimes lead to static compilation issues though: #531. |
We can potentially generalize this to have an operation that can assert whether a value is of some type, not just for enums. (much like Java's On the other hand - we have also discussed introducing a concept such as dynamic dispatch for functions (much like how method overriding works in Java), or having a concept similar to Haskell's type classes (somewhat more extensible than dynamic dispatch). Taking this route might make the above operation superfluous. Something worth discussing. |
Dynamic dispatch functions are discussed in issue #546 |
I think this is the correct solution. However it would require a significant amount of Java code generation work to implement because Rosetta enums are currently generated as native Java enums. This is a problem because Java enums do not support inheritance, so to implement this the Java code generation would need to generate an enum abstraction (e.g. wrap it in a class). |
An interim solution which would be useful in other scenarios would be to provide a
A
|
Enumeration supports extension, where an extended
enum
adds enumerated values to a baseenum
. However those values have to be directly listed in the extendedenum
.For reporting purposes, we would like the DSL to support extending an
enum
with the values of anotherenum
rather than having to specify those values individually.This applies in the CDM in the context of a rate option which can either be a floating rate (
FloatingRateIndexEnum
) or an inflation rate (InflationRateIndexEnum
). For reporting purposes this may have to be reported as a singleenum
which is a merge of the two.The text was updated successfully, but these errors were encountered: