facebook

Java Enum

  1. MyEclipse IDE
  2.  > 
  3. Spring Development
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #309752 Reply

    jaybytez
    Member

    Through the Spring DSL, how do you create a Java Enum?

    Thanks,

    Jay

    #309787 Reply

    Heflin Hogan
    Member

    Jay,

    We don’t currently support Enum in the DSL. You can still manually add them into the code where you need them, though.

    Heflin

    #315875 Reply

    Peter
    Member

    I was hoping this would be available with ME4S 9!

    Is this in the works to be in future releases? If not, what is a good workaround for this?

    #315942 Reply

    jkennedy
    Member

    Sorry this did not make it into the 9.0 release. I will make sure we get it voted up in our product management system. We haven’t nailed down what will be going into 9.0 maintenance at this point. Regarding a work around, it depends on your needs I think. Some people use “code tables” to manage this sort of thing, basically creating an instance in your DataModel for the Enum type and letting its data and possible values be controlled by what data is in the DB. One benefit to this is that you can control the list of possible values without changing the code should a new option pop up in the future. I suppose another potential approach (although I haven’t tried it) would be to code the Enum as you normally would, but add a field to your Persisted domain model that stores the enum value and then add the getters/setters that would let you receive one of the Enumeration elements (but call the setter to pass the enum “value”) to the DB. Then override the getter to do the same in reverse.

    so your Entity might have a persisted field that is:
    private long enumValue;
    public long getEnumValue()
    public void setEnumValue()

    Then you would have utility methods on the Entity that were something like
    public MyEnum getEnum () {
    return Enum.get(getEnumValue());
    }
    etc.

    Let me know what you decide.
    Thanks,
    Jack

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: Java Enum

You must be logged in to post in the forum log in