package cn.sikey.hmd.enums;

import cn.hutool.core.util.ArrayUtil;
import cn.sikey.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 有效期
 */
@AllArgsConstructor
@Getter
public enum ValidityEnum implements IntArrayValuable {

    ZERO(0, "0:默认天数"),YEAR(1, "年");

    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ValidityEnum::getValue).toArray();

    /**
     * value
     */
    private final Integer value;
    /**
     * name
     */
    private final String name;

    public static ValidityEnum valueOf(Integer value) {
        return ArrayUtil.firstMatch(userType -> userType.getValue().equals(value), ValidityEnum.values());
    }

    @Override
    public int[] array() {
        return ARRAYS;
    }
}
