first commit.

This commit is contained in:
2022-11-07 17:49:27 +08:00
commit 0d5eef24e3
9 changed files with 349 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
package xyz.zhouxy.plusone.util;
import java.util.HashMap;
import java.util.Map;
public final class EnumerationValuesHolder<T extends Enumeration<T>> {
private final Map<Integer, T> constants = new HashMap<>();
public EnumerationValuesHolder(T[] values) {
for (T value : values) {
put(value);
}
}
private void put(T constant) {
this.constants.put(constant.getValue(), constant);
}
public T get(int value) {
return this.constants.get(value);
}
}