I have an enum a I would like set a value (exampleValue) based on another value (size). Of course this does not work, because I can't use this in a static context.
private enum FIELDS {
FIELD_2("Field 1", 1, 8, StringUtils.leftPad("A", this.getSize(), "X")),
FIELD_3("Field 2", 2, 7, StringUtils.leftPad("A", this.getSize(), "X")) ,
FIELD_4("Field 3", 3, 9, StringUtils.leftPad("A", this.getSize(), "X"));
private final String description;
private final int number;
private final int size;
private final String exampleValue;
FIELDS(String description, int number, int size, String exampleValue) {
this.description = description;
this.number = number;
this.size = size;
this.exampleValue = exampleValue;
}
public String getDescription() {
return description;
}
public int getNumber() {
return number;
}
public int getSize() {
return size;
}
public String getExampleValue() {
return exampleValue;
}
}
But is there a clean Java-esque way to do it?