Skip to content

Commit 297019c

Browse files
Stephan202Error Prone Team
authored andcommitted
Fix some mistakes in the EnumOrdinal examples
PiperOrigin-RevId: 610431336
1 parent f3dbb09 commit 297019c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

docs/bugpattern/EnumOrdinal.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,18 @@ Prefer using enum value directly:
99
ImmutableMap<MyEnum, String> MAPPING =
1010
ImmutableMap.<MyEnum, String>builder()
1111
.put(MyEnum.FOO, "Foo")
12-
.put(MyEnum.BAR, "Bar");
12+
.put(MyEnum.BAR, "Bar")
13+
.buildOrThrow();
1314
```
1415

1516
to this:
1617

1718
```java
18-
ImmutableMap<Integer, String> MAPPING =
19-
ImmutableMap.<MyEnum, String>builder()
19+
ImmutableMap<Integer, String> MAPPING =
20+
ImmutableMap.<Integer, String>builder()
2021
.put(MyEnum.FOO.ordinal(), "Foo")
21-
.put(MyEnum.BAR.ordinal(), "Bar");
22+
.put(MyEnum.BAR.ordinal(), "Bar")
23+
.buildOrThrow();
2224
```
2325

2426
Or if you need a stable number for serialisation, consider defining an explicit

0 commit comments

Comments
 (0)