package cn.iocoder.yudao.module.bpm.enums.task;

import cn.hutool.core.util.ArrayUtil;
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum BpmMultiTaskEnum implements ArrayValuable<Integer> {

    APPROVAL_IN_SEQUENCE(1, "1"),

    COUNTERSIGN(2, "${ nrOfCompletedInstances >= nrOfInstances }"),

    ANY_ONE(3, "${ nrOfCompletedInstances > 0 }");

    public static final Integer[] ARRAYS = Arrays.stream(values()).map(BpmMultiTaskEnum::getValue).toArray(Integer[]::new);

    /**
     * 状态
     */
    private final Integer value;
    /**
     * 转改名
     */
    private final String name;

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

    public static BpmMultiTaskEnum nameOf(String name) {
        return ArrayUtil.firstMatch(userType -> userType.getName().equals(name), BpmMultiTaskEnum.values());
    }

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