55 return color;
56 }
57
58 public enum Color { 59 RED, GREEN, BLUE, YELLOW, BLACK; 60 61 @Override 62 public String toString() { 63 switch (this) { 64 case RED -> { 65 return "R"; 66 } 67 case BLUE -> { 68 return "B"; 69 } 70 case BLACK -> { 71 return "Black"; 72 } 73 case GREEN -> { 74 return "G"; 75 } 76 case YELLOW -> { 77 return "Y"; 78 } 79 default -> { 80 return ""; 81 } 82 } 83 } 84 } 85
86 public enum Type {
87 ZERO("0"), ONE("1"), TWO("2"), THREE("3"), FOUR("4"), FIVE("5"), SIX("6"), SEVEN("7"),
83 }
84 }
85
86 public enum Type { 87 ZERO("0"), ONE("1"), TWO("2"), THREE("3"), FOUR("4"), FIVE("5"), SIX("6"), SEVEN("7"), 88 EIGHT("8"), NINE("9"), DRAW_TWO("D2"), REVERSE("R"), SKIP("S"), WILDE("W"), 89 WILDE_DRAW_FOUR("WD4"); 90 private final String name; 91 92 Type(String name) { 93 this.name = name; 94 } 95 96 public static Type byName(String name) { 97 for (Type value : values()) { 98 if (value.name.equals(name)) { 99 return value;100 }101 }102 return null;103 }104105 public String getName() {106 return name;107 }108 }109}
183 }
184
185
186 public enum State {187 LOBBY,188 IN_GAME,189 FINISHED190 }191}
This declaration is not documented.
Consider adding a documentation comment to explain its functionality.
While it may seem like the functionality of this declaration is perfectly obvious, any consumers of your API or future maintainers may not be able to pick up on certain details.
In the example below, the meaning of AUIHighlight
may not be entirely clear, and questions such as what AUI
means may pop up.
public enum AUIHighlight {
LIGHT_BLUE(0x00ADD8E6),
DARK_BLUE(0x0000008B),
// ...
private int value;
AUIHighlight(int val) {
value = val;
}
}
Make sure to document any non-obvious details about any code element.
/**
* UI highlight color values for the action bar of the application.
*/
public enum AUIHighlight {
// ...
}