-
1. Re: Enum data types in Forge
gastaldi Mar 21, 2013 8:13 PM (in response to johnsylora)Hello John !
If you're using Forge 1.2.1.Final onwards, you may be able to create enums like this:
$ java new-enum-type --named PartType --package ~.model
As for creating the enum constants, you're doing the correct way.
To include your enum in another class, you may use the the code you're using or if you have Persistence enabled in you project, you may simply use:
$ field custom --named partType --type ~.model.PartType.java
As this will also create getters and setters for your field.
Best Regards,
George Gastaldi
-
2. Re: Enum data types in Forge
johnsylora Mar 21, 2013 11:24 PM (in response to gastaldi)Thank you George.. the answer was perfect. I would like to extend this discussion to the general use of enums vs lists.
1) In my example above, if my PartType enum class contains several items which I want the user to be able to add or delete from, is my use of the enum type incorrect? Will it be difficult/impossible for the user to change the items in the enum class? Should the use of enums be limited to lists of items which will definitely not change and which the user cannot change? For example the months of the year, days of week etc..
2) In the case when the list of items may change, is it better to use a list? If so what would be an ideal way of implementing this?
Thank you..