/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.security.flow.core.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.EnumSet;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 审批候选人类型
 *
 * @author Arlex
 */
@Getter
@AllArgsConstructor
public enum CandidateTypeEnum {

	/**
	 * 总行领导
	 */
	HEAD_LEADER("headLeader", "总行领导"),

	/**
	 * 总行安全部部门领导
	 */
	HEAD_SEC_LEADER("headSecLeader", "总行安全部部门领导"),

	/**
	 * 总行安全员
	 */
	HEAD_SAFER("headSafer", "总行安全员"),

	/**
	 * 分行领导
	 */
	BRANCH_LEADER("branchLeader", "分行领导"),

	/**
	 * 分行安全员
	 */
	BRANCH_SAFER("branchSafer", "分行安全员"),

	/**
	 * 支行领导
	 */
	SUB_LEADER("subLeader", "支行领导"),

	/**
	 * 支行安全员
	 */
	SUB_SAFER("subSafer", "支行安全员"),

	/**
	 * 部门领导
	 */
	DEPT_LEADER("deptLeader", "部门领导"),

	/**
	 * 总行安保指挥中心全员
	 */
	HEAD_SEC_CENTER_ALL("securityUser", "总行安保指挥中心全员"),

	/**
	 * 分行安保指挥中心全员
	 */
	BRANCH_SEC_CENTER_ALL("branchSecurityUser", "分行安保指挥中心全员"),
	;

	final String value;

	final String name;

	public static CandidateTypeEnum fromValue(String value) {
		if (null == value) {
			throw new IllegalArgumentException("Invalid value: " + value);
		}
		return EnumSet.allOf(CandidateTypeEnum.class).stream()
			.filter(s -> s.getValue().equals(value))
			.findAny()
			.orElseThrow(() -> new IllegalArgumentException("Invalid value: " + value));
	}

	public static List<String> getValues() {
		List<String> list = Stream.of(CandidateTypeEnum.values()).map(CandidateTypeEnum::getValue).collect(Collectors.toList());
		return list;
	}

}
