1

I'd like to create the following Java source code using JCodeModel

public enum MyEnum {
    FIRST_CONSTANT {

        @Override
        public String toString() {
            return "first";
        }
    },
    SECOND_CONSTANT {

        @Override
        public String toString() {
            return "second";
        }
    };

    public abstract String toString();
}

But JEnumConstant does not expose methods to define the enum constant's body.

Is there a way to achieve this? Moreover I noticed that JCodeModel does not support certain JDK 7 oder JDK 8 features like try with resources. Is there an alternative source code generation utility?

ooxi
  • 3,159
  • 2
  • 28
  • 41

1 Answers1

1

Unfortunately, you are correct. the Latest version of JCodeModel (2.6) does not have the capabilities to generate enum constant methods.

John Ericksen
  • 10,995
  • 4
  • 45
  • 75