3 Replies Latest reply on Jan 14, 2013 3:14 PM by gimbal2

    Advanced enum handling with generics

      Hi everybody,

      i am looking for an optimal solution for my enum issue:
      I got a group of different enums all implementing my Interface XYZ. I create the interface to be sure all enums containing an additional property value

      Here is my problem: Instead of writing a valueForProperty(String property) -method for every enum i have created a method that can be used by all my enums that implements the interface XYZ.
      public Enum<?> valueForProperty(String propertyValue, Enum<? extends XYZ>... enums){
      - The good thing about this method is, that i can only put enums of type XYZ in it
      - the bad thing is that i have to make a cast when using this method because the return value is only an enum
      IWantThisEnum enum = (IWantThisEnum)this.valueForProperty("thisIsAPropertyValue", IWantThisEnum.values());
      Has anyone an idea to avoid that cast here?

      Best regards

      Edited by: user8973009 on 14.01.2013 15:23

      Edited by: user8973009 on 14.01.2013 15:23