Home › Forums › Business Model › Enumerations › Enumeration Inheritance
- This topic has 2 replies, 2 voices, and was last updated 6 years, 8 months ago by Aditya Phatak.
November 16, 2015 at 12:54 pm #414Ed ShawKeymaster
uestion originally posed by KamalAman – here for reference
Is there anyway to have one enumeration inherit from another enumeration like what can be done with classes?
I’m trying to model specifications for products in a flexible way such that a product will have a collections of specifications. See the attached picture of a snippet for the specification architecture.
Is it possible for enums to build off of each other such as: SpecificationEnum <– ProductSpecEnum <– MachineSpecEnum . Having giant enum wouldnt be ideal. Some sudo code: Specification spec1 = new Measure ((: specNameEnum MachineSpecEnum'CuttingSpeed) (: unit PressureUnitEnum'mpinch) (: value 5))) ==> “Cutting Speed”, 5 m/1′
I see that there are fields in the Enum forum for Base, Parent, Association, and Reverse. Any ideas?
Attachments:You must be logged in to view attached files.
November 17, 2015 at 4:44 pm #416Ed ShawKeymaster
Just use the base property for your base enumeration and the sub enumeration will include all of be base enumeration’s values as well.
Also, with regard to the Parent, Association and Reverse properties on the enum…
These set up associations with correct types between enum classes, i.e. one parent instance can have zero or more child instances, and each child instance can have up to one parent instance. Have a look at the class diagram named Enums.cd in NexJ Studio.1
September 22, 2016 at 2:44 am #7568Aditya PhatakParticipant
To add to above point:
Association property uses an identifier to associate the child enumeration to its parent.
Reverse property uses an identifier to bring the parent enumeration context into its child enumerations.
For example, lets say we have a Country enumeration (CountryEnum) which has 3 values: India, Canada and England. We have a State enumeration (StateEnum) which has different values like: Maharashtra, Ontario, Berkshire, etc. Each of these values would have a Parent Value specified (Maharashtra => India, Berkshire => England and likewise).
For State enumeration, we specify below values for the properties:
So, when we access the enumerations, it will be something of sort:
(StateEnum’get ‘Maharashtra) -> gives you an enum instance
((StateEnum’get ‘Maharashtra)’country) -> gives you an enum instance of the country
(((StateEnum ‘get ‘Maharashtra)’ country)’caption) –> gives you “India”
((CountryEnum’get ‘India)’states) –> gives you state enum as multiple instances
(((CountryEnum’get ‘India)’states)’caption) –> gives you list of state values, i.e.
- You must be logged in to reply to this topic.