
package cn.orionsec.ops.constant.common;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum EnableType {

    /**
     * 启用
     */
    ENABLED(Boolean.TRUE, "enabled"),

    /**
     * 停用
     */
    DISABLED(Boolean.FALSE, "disabled"),

    ;

    private final Boolean value;

    private final String label;

    public static EnableType of(String label) {
        if (label == null) {
            return DISABLED;
        }
        for (EnableType value : values()) {
            if (value.label.equals(label)) {
                return value;
            }
        }
        return DISABLED;
    }

    public static EnableType of(Boolean value) {
        if (value == null) {
            return DISABLED;
        }
        for (EnableType type : values()) {
            if (type.value.equals(value)) {
                return type;
            }
        }
        return DISABLED;
    }

}
