Skip to content

Commit a60b31e

Browse files
committed
Replaced anonymous HashMap with Map.ofEntries
Streamlined initialization for better readability and immutability.
1 parent 3ec29f9 commit a60b31e

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

nbt/src/main/java/core/nbt/NBTInputStream.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -106,21 +106,21 @@ public Charset getCharset() {
106106
/**
107107
* Mappings between tag type ids and the corresponding mapping function
108108
*/
109-
private final Map<Integer, MappingFunction> mapper = new HashMap<>() {{
110-
put(ByteArrayTag.ID, ByteArrayTag::read);
111-
put(ByteTag.ID, ByteTag::read);
112-
put(CompoundTag.ID, CompoundTag::read);
113-
put(DoubleTag.ID, DoubleTag::read);
114-
put(EscapeTag.ID, ignored -> EscapeTag.INSTANCE);
115-
put(FloatTag.ID, FloatTag::read);
116-
put(IntArrayTag.ID, IntArrayTag::read);
117-
put(IntTag.ID, IntTag::read);
118-
put(ListTag.ID, ListTag::read);
119-
put(LongArrayTag.ID, LongArrayTag::read);
120-
put(LongTag.ID, LongTag::read);
121-
put(ShortTag.ID, ShortTag::read);
122-
put(StringTag.ID, StringTag::read);
123-
}};
109+
private final Map<Integer, MappingFunction> mapper = new HashMap<>(Map.ofEntries(
110+
Map.entry(ByteArrayTag.ID, ByteArrayTag::read),
111+
Map.entry(ByteTag.ID, ByteTag::read),
112+
Map.entry(CompoundTag.ID, CompoundTag::read),
113+
Map.entry(DoubleTag.ID, DoubleTag::read),
114+
Map.entry(EscapeTag.ID, ignored -> EscapeTag.INSTANCE),
115+
Map.entry(FloatTag.ID, FloatTag::read),
116+
Map.entry(IntArrayTag.ID, IntArrayTag::read),
117+
Map.entry(IntTag.ID, IntTag::read),
118+
Map.entry(ListTag.ID, ListTag::read),
119+
Map.entry(LongArrayTag.ID, LongArrayTag::read),
120+
Map.entry(LongTag.ID, LongTag::read),
121+
Map.entry(ShortTag.ID, ShortTag::read),
122+
Map.entry(StringTag.ID, StringTag::read)
123+
));
124124

125125
/**
126126
* Register a custom tag mapping

0 commit comments

Comments
 (0)