package com.caliverse.admin.dynamodb.entity;


import com.caliverse.admin.domain.entity.common.ValueEnum;
import com.fasterxml.jackson.annotation.JsonCreator;

public enum ECurrencyType implements ValueEnum {
    None(0),
    Gold(1),
    Sapphire(2),
    Calium(3),
    Beam(4),
    Ruby(5),
    ;

    private final int value;

    ECurrencyType(int value) {
        this.value = value;
    }

    @Override
    public int getValue() {
        return value;
    }

    @JsonCreator
    public static ECurrencyType fromValue(Object value) {
        if (value instanceof Number) {
            int intValue = ((Number) value).intValue();
            for (ECurrencyType type : values()) {
                if (type.value == intValue) {
                    return type;
                }
            }
        } else if (value instanceof String) {
            String stringValue = (String) value;
            for (ECurrencyType type : values()) {
                if (type.name().equalsIgnoreCase(stringValue)) {
                    return type;
                }
            }
        }
        throw new IllegalArgumentException("Invalid ECurrencyType value: " + value);
    }

}
