Skip to content

Best practice for enums that implement interfaces? #299

@antch

Description

@antch

In my codebase I have a bunch of enums that follow the pattern:

public enum MyEnum implements Descriptive {

  VAL1("Value 1 Description"), VAL2("Value 2 Description");
  
  private String description;

  private MyEnum(String description) {
    this.description = description;
  }

  @Override
  public String getDescription() {
    return this.description;
  }

  public String getCustomField() {
    //specific to this enum, not part of an interface
  }
  
}

In this case there is value to having a TypeScript enum for just the enum values (current behavior), but in some cases we need to deal with the MyEnum fields and super-interfaces so having the ability to generate those as well would be really useful. Right now we have to manually create additional types for each enum.

Is there any way to get the generator to create the enum with just the values, as it does now, as well as to create them as classes with proper inheritance?

I do see ClassEnumExtension but I don't think that supports generating multiple types?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions