001/*
002 *    Copyright 2024-2025, Warm-Flow (290631660@qq.com).
003 *
004 *    Licensed under the Apache License, Version 2.0 (the "License");
005 *    you may not use this file except in compliance with the License.
006 *    You may obtain a copy of the License at
007 *
008 *       https://www.apache.org/licenses/LICENSE-2.0
009 *
010 *    Unless required by applicable law or agreed to in writing, software
011 *    distributed under the License is distributed on an "AS IS" BASIS,
012 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *    See the License for the specific language governing permissions and
014 *    limitations under the License.
015 */
016package org.dromara.warm.flow.core.enums;
017
018import org.dromara.warm.flow.core.utils.StringUtils;
019
020/**
021 * 审批动作
022 *
023 * @author warm
024 * @since 2023/3/31 12:16
025 */
026public enum SkipType {
027    PASS("PASS", "审批通过"),
028    REJECT("REJECT", "退回"),
029    NONE("NONE", "无动作");
030
031    private String key;
032    private String value;
033
034    SkipType(String key, String value) {
035        this.key = key;
036        this.value = value;
037    }
038
039    public static String getKeyByValue(String value) {
040        for (SkipType item : SkipType.values()) {
041            if (item.getValue().equals(value)) {
042                return item.getKey();
043            }
044        }
045        return null;
046    }
047
048    public static String getValueByKey(String key) {
049        for (SkipType item : SkipType.values()) {
050            if (item.getKey().equals(key)) {
051                return item.getValue();
052            }
053        }
054        return null;
055    }
056
057    public static SkipType getByKey(String key) {
058        for (SkipType item : SkipType.values()) {
059            if (item.getKey().equals(key)) {
060                return item;
061            }
062        }
063        return null;
064    }
065
066    /**
067     * 判断是否通过类型
068     *
069     * @param Key
070     * @return
071     */
072    public static Boolean isPass(String Key) {
073        return StringUtils.isNotEmpty(Key) && (SkipType.PASS.getKey().equals(Key));
074    }
075
076    /**
077     * 判断是否退回类型
078     *
079     * @param Key
080     * @return
081     */
082    public static Boolean isReject(String Key) {
083        return StringUtils.isNotEmpty(Key) && (SkipType.REJECT.getKey().equals(Key));
084    }
085
086    /**
087     * 判断是否无动作类型
088     *
089     * @param Key
090     * @return
091     */
092    public static Boolean isNone(String Key) {
093        return StringUtils.isNotEmpty(Key) && (SkipType.NONE.getKey().equals(Key));
094    }
095
096    public String getKey() {
097        return key;
098    }
099
100    public String getValue() {
101        return value;
102    }
103}