All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.zodiac.sdk.json.ext.EnumWrapper Maven / Gradle / Ivy

There is a newer version: 1.5.17
Show newest version
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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy