Home Forums Business Model Enumerations Enumeration Inheritance

Tagged: 

Viewing 2 reply threads
  • Author
    Posts
    • #414
      Ed ShawEd Shaw
      Keymaster

      uestion originally posed by KamalAman – here for reference

      Hi,

      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?

      Thanks,

      0
      Attachments:
      You must be logged in to view attached files.
    • #416
      Ed ShawEd Shaw
      Keymaster

      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
    • #7568
      Aditya PhatakAditya Phatak
      Participant

      Hi,

      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:

      Parent: CountryEnum

      Association: states

      Reverse: country

      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

      and finally,

      (((CountryEnum’get ‘India)’states)’caption) –> gives you list of state values, i.e.

      #<[Gujarat, Maharashtra]>

       

      Regards,

      AP.

      1
Viewing 2 reply threads
  • You must be logged in to reply to this topic.