diff --git a/proxy/src/main/java/com/velocitypowered/proxy/util/collect/Enum2IntMap.java b/proxy/src/main/java/com/velocitypowered/proxy/util/collect/Enum2IntMap.java index 714a0c8c1..25c22d364 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/util/collect/Enum2IntMap.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/util/collect/Enum2IntMap.java @@ -2,6 +2,10 @@ package com.velocitypowered.proxy.util.collect; import java.util.EnumSet; +/** + * An immutable map of {@link Enum} entries to {@code int}s. + * @param the enum type + */ public class Enum2IntMap> { private final int[] mappings; @@ -23,6 +27,12 @@ public class Enum2IntMap> { this.populated = EnumSet.noneOf(klazz); } + /** + * Adds a mapping to the map. + * @param key the key to use + * @param value the value to associate with the key + * @return {@code this}, for chaining + */ public Builder put(E key, int value) { this.mappings[key.ordinal()] = value; this.populated.add(key); @@ -39,6 +49,11 @@ public class Enum2IntMap> { return this; } + /** + * Fetches a mapping from the map. + * @param key the key to use + * @return the value in the map + */ public int get(E key) { if (this.populated.contains(key)) { return this.mappings[key.ordinal()]; @@ -46,6 +61,10 @@ public class Enum2IntMap> { return this.defaultValue; } + /** + * Builds the map. + * @return the built map + */ public Enum2IntMap build() { for (E unpopulated : EnumSet.complementOf(this.populated)) { this.mappings[unpopulated.ordinal()] = this.defaultValue;