org.zodiac.sdk.json.ext.EnumWrapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zodiac-sdk-json Show documentation
Show all versions of zodiac-sdk-json Show documentation
Zodiac SDK JSON(JavaScript Object Notation)
package org.zodiac.sdk.json.ext;
import java.util.HashMap;
import java.util.Map;
public class EnumWrapper {
protected final Map enumMap = new HashMap<>();
protected final Enum[] enumOrdinal;
public EnumWrapper(Class> enumClass){
enumOrdinal = (Enum[]) enumClass.getEnumConstants();
for (int i = 0; i < enumOrdinal.length; ++i) {
Enum e = enumOrdinal[i];
String name = e.name();
enumMap.put(name,e);
}
}
public Enum get(int ordinal){
return enumOrdinal[ordinal];
}
public Enum get(String name){
return enumMap.get(name);
}
}