Skip to content

Commit b9337a0

Browse files
authored
Update README.md
1 parent 1861cc8 commit b9337a0

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

README.md

+57
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,63 @@
33
# java11-enum-clean-code
44
Overview of how to to construct modern enums using lambda.
55

6+
# enum compliation
7+
* https://stackoverflow.com/questions/32354107/how-are-enums-internally-represented-in-java
8+
* only syntactic sugar
9+
10+
```
11+
public enum Ordinals {
12+
FIRST("st"),
13+
SECOND("nd"),
14+
THIRD("rd");
15+
private String notation;
16+
private Ordinals(String notation) {
17+
this.notation = notation;
18+
}
19+
public String getNotation() {
20+
return notation;
21+
}
22+
}
23+
```
24+
25+
```
26+
public final class Ordinals extends java.lang.Enum<Ordinals> {
27+
public static final Ordinals FIRST;
28+
29+
public static final Ordinals SECOND;
30+
31+
public static final Ordinals THIRD;
32+
33+
private String notation;
34+
35+
private static final Ordinals[] $VALUES;
36+
37+
public static Ordinals[] values() {
38+
return $VALUES.clone();
39+
}
40+
41+
public static Ordinals valueOf(String name) {
42+
return (Ordinals) Enum.valueOf(Ordinals.class, name);
43+
}
44+
45+
private Ordinals(String name, int ordinal, String notation) {
46+
super(name, ordinal);
47+
this.notation = notation
48+
}
49+
50+
static {
51+
FIRST = new Ordinals("FIRST", 0, "st");
52+
SECOND = new Ordinals("SECOND", 1, "nd");
53+
THIRD = new Ordinals("THIRD", 2, "rd");
54+
Ordinals[] $VALUES = new Ordinals[3];
55+
$VALUES[0] = FIRST;
56+
$VALUES[1] = SECOND;
57+
$VALUES[2] = THIRD;
58+
Ordinals.$VALUES = $VALUES;
59+
}
60+
}
61+
```
62+
663
# project description
764
We have enum `JobTitle`
865

0 commit comments

Comments
 (0)