cmoine / generic-enums

Attempt to implement https://openjdk.java.net/jeps/301 with annotation + processor
MIT License
7 stars 1 forks source link

Implement support for nested enums #2

Closed cloudpay-simon closed 2 years ago

cloudpay-simon commented 2 years ago

Implement support for enums within classes. Currently only support nesting of one level. Added support for non-generic interfaces (e.g. Serializable)

public class MyClass implements Serializable {

  public enum MyEnum {
    ONE, TWO
  }
}

Added integration tests.

cmoine commented 2 years ago

I don't totally understand the motivation behind this. I think that if we take annotation processors like "Immutables", nested immutable interfaces are generating a top level class. Isn't it how it behaves at the moment? Or the behavior would fit to you ?

cloudpay-simon commented 2 years ago

Hi Christophe,

Firstly, sorry for the state of this PR. Lots of unrelated changes in just 1 commit. I should break it up into different PRs.

The functionality I'm after is to be able to do:

public class Field {

  public enum User {
    NAME,
    DOB
  }

  public enum Address {
    HOUSE_NUMBER,
    TOWN,
    CITY
    ZIP_CODE
  }
}

and generate the same structure. FieldExt containing two enums UserExt and AddressExt. I'm trying to maintain source code level compatibility, I don't want to have to update 100s of files.

Simon

cloudpay-simon commented 2 years ago

I've split this PR in to 3 parts