package com.caliverse.admin.dynamodb.entity;

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

public enum ECountDeltaType implements ValueEnum {
    None(0),
    New(1),
    Update(2),
    Acquire(3),
    Consume(4),
    Delete(5),
    ;

    private final int value;

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

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

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