package com.brilliance.mda.support.cache.serializer;


import com.brilliance.mda.support.cache.serializer.impl.KryoSerializer;

public enum ICacheSerializerEnum {

    Kryo("kryo", new KryoSerializer());

    private String key;

    private ICacheSerializer serializer;

    ICacheSerializerEnum(String key, ICacheSerializer serializer) {
        this.key = key;
        this.serializer = serializer;
    }

    public static ICacheSerializer getSerializer(String key) {
        for (ICacheSerializerEnum e : ICacheSerializerEnum.values()) {
            if (e.key.equals(key))
                return e.getSerializer();
        }
        return ICacheSerializerEnum.values()[0].getSerializer();
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public ICacheSerializer getSerializer() {
        return serializer;
    }

    public void setSerializer(ICacheSerializer serializer) {
        this.serializer = serializer;
    }
}
