Open
Description
It would be great if Manifold could support a more concise, record-style syntax for enum classes that have parameters and corresponding getters.
Currently, defining such enums requires boilerplate code like this:
public enum Day() {
MONDAY(1, "Monday"),
TUESDAY(2, "Tuesday"), ...
private final int dayOfTheWeek;
private final String value;
Day(int dayOfTheWeek String value){
this.dayOfTheWeek = dayOfTheWeek;
this.value=value;
}
public int getDayOfTheWeek(){
return dayOfTheWeek;
}
public String getValue(){
return value;
}
}
Similar to how records reduce boilerplate, this could be rewritten as:
public enum Day(int dayOfTheWeek, String value) {
MONDAY(1, "Monday"),
TUESDAY(2, "Tuesday"), ...
}
As with records, developers should still be able to define a custom constructor if needed to improve flexibility:
public enum Day(int dayOfTheWeek, String value) {
MONDAY(1, "Monday"),
TUESDAY(2, "Tuesday"), ...
Day(int dayOfTheWeek String value){
this.dayOfTheWeek = dayOfTheWeek;
this.value = dayOfTheWeek + " - " + value;
}
}