package cn.estsh.i3plus.pojo.base.enumutil;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description : 软适配 枚举接口
 * @Reference :
 * @Author : yunhao
 * @CreateDate : 2019-08-13 9:34
 * @Modify:
 **/
public class BlockSoftSwitchEnumUtil {

    /**
     * 套件类型
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum CASE_TYPE{
        SOCKET(10,"SOCKET套件"),
        RESTFUL(20,"RESTFUL套件"),
        DATASOURCE(30,"数据源套件"),
        WEB_SERVICE(40,"WebService套件"),
        MQ(50,"消息队列套件"),
        WEB_SOCKET(60,"WebSocket套件"),
        FTP(70,"FTP套件");

        private int value;
        private String description;

        CASE_TYPE(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static CASE_TYPE valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    return values()[i];
                }
            }
            return null;
        }
    }

    /**
     * 适配模式
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum SUIT_MODE{
        CLIENT(1,"客户端"),
        SERVER(2,"服务端");

        private int value;
        private String description;

        SUIT_MODE(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static SUIT_MODE valueOf(int val) {
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    return values()[i];
                }
            }
            return null;
        }
    }

    /**
     * 软适配命令集合
     * <per>
     * <br/> ID 编号规则
     * <br/>      第一位             服务端或者客户端 1 或者 2
     * <br/>      第二至三位         适配类型编号
     * <br/>      后三位             适配器ID升序
     * </per>
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum SOFTS_WITCH_ACTION{
        /* WebService */
        SERVER_WEB_SERVICE_SEND_EMAIL(SUIT_MODE.SERVER,CASE_TYPE.WEB_SERVICE,240001,"Server IMPP 服务邮件服务"),
        SERVER_WEB_SERVICE_HELLO(SUIT_MODE.SERVER,CASE_TYPE.WEB_SERVICE,240003,"Server Hello测试服务"),
        SERVER_WEB_SERVICE_RECORDING_XML(SUIT_MODE.SERVER,CASE_TYPE.WEB_SERVICE,240004,"记录请求Body"),
//        CLIENT_WEB_SERVICE_HELLO(SUIT_MODE.CLIENT,CASE_TYPE.WEB_SERVICE,140002,"Client IMPP邮件测试"),
        CLIENT_WEB_SERVICE_DEFAULT(SUIT_MODE.CLIENT,CASE_TYPE.WEB_SERVICE,140003,"Client 默认设置"),
        CLIENT_WEB_SERVICE_PARAM_OBJECT(SUIT_MODE.CLIENT,CASE_TYPE.WEB_SERVICE,140004,"Client Param Object"),

        /* 数据源 */
        CLIENT_DATA_SOURCE_IMPP(SUIT_MODE.CLIENT,CASE_TYPE.DATASOURCE,130001,"Client 数据库适配服务"),

        /* Restful */
        CLIENT_RESTFUL_IMPP(SUIT_MODE.CLIENT,CASE_TYPE.RESTFUL,120001,"Client REST客户端适配器"),
        SERVER_RESTFUL_IMPP(SUIT_MODE.SERVER,CASE_TYPE.RESTFUL,220001,"Client REST服务端适配器"),

        /* Socket */
        SERVER_SOCKET_HELLO(SUIT_MODE.SERVER ,CASE_TYPE.SOCKET,210001,"Socket Server Hello测试服务"),
        CLIENT_SOCKET_HELLO(SUIT_MODE.CLIENT ,CASE_TYPE.SOCKET,110001,"Socket Client Hello测试服务"),

        /* MQ */
        SERVER_MQ_RABBIT_HELLO(SUIT_MODE.SERVER ,CASE_TYPE.MQ,250001,"RabbitMQ Server Hello测试服务"),
        CLIENT_MQ_RABBIT_HELLO(SUIT_MODE.CLIENT ,CASE_TYPE.MQ,150001,"RabbitMQ Client Hello测试服务"),

        /* FTP */
        CLIENT_FTP_IMPP(SUIT_MODE.CLIENT,CASE_TYPE.FTP,160001,"Client FTP客户端适配器"),
        SERVER_FTP_IMPP(SUIT_MODE.SERVER,CASE_TYPE.FTP,260001,"Client FTP服务端适配器");

        private int value;
        private String description;
        private String clazzName;
        private SUIT_MODE mode;
        private CASE_TYPE type;

        SOFTS_WITCH_ACTION(SUIT_MODE mode, CASE_TYPE type,int value, String description) {
            this.value = value;
            this.description = description;
            this.mode = mode;
            this.type = type;
        }

        SOFTS_WITCH_ACTION(SUIT_MODE mode, CASE_TYPE type,int value, String clazzName, String description) {
            this.value = value;
            this.description = description;
            this.clazzName = clazzName;
            this.mode = mode;
            this.type = type;
        }

        public static SOFTS_WITCH_ACTION valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    return values()[i];
                }
            }
            return null;
        }

        public static SOFTS_WITCH_ACTION[] valueOfCaseType(CASE_TYPE type) {
            List<SOFTS_WITCH_ACTION> result = new ArrayList<>();
            for (int i = 0; i < values().length; i++) {
                if (values()[i].type.equals(type)) {
                    result.add(values()[i]);
                }
            }
            return result.toArray(new SOFTS_WITCH_ACTION[result.size()]);
        }

        public static SOFTS_WITCH_ACTION[] valueOfMode(SUIT_MODE mode) {
            List<SOFTS_WITCH_ACTION> result = new ArrayList<>();
            for (int i = 0; i < values().length; i++) {
                if (values()[i].mode.equals(mode)) {
                    result.add(values()[i]);
                }
            }
            return result.toArray(new SOFTS_WITCH_ACTION[result.size()]);
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public String getClazzName() {
            return clazzName;
        }

        public SUIT_MODE getMode() {
            return mode;
        }

        public CASE_TYPE getType() {
            return type;
        }
    }

    /**
     * 请求来源
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum REQUEST_SOURCE{
        ACTIVE(1,"主动请求"),
        SCHEDULE(2,"定时调度"),
        RABBITMQ(3,"MQ 调用"),
        HTTP(4,"接口调用"),
        CLOUD(5,"微服务调用"),
        REST(6,"REST调用"),
        WEB_SERVICE(7,"WebService"),
        SOCKET(8,"socket"),
        RETRY(9,"重试");

        private int value;
        private String description;

        REQUEST_SOURCE(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }
    }

    /**
     * 认证方式
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum VERIFICATION_METHOD{
        IMPP_LOGIN(1,"IMPP登录");

        private int value;
        private String description;

        VERIFICATION_METHOD(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static VERIFICATION_METHOD valueOf(int val) {
            VERIFICATION_METHOD tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i];
                }
            }
            return tmp;
        }
    }

    /**
     * 认证类型
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum KEY_TYPE{
        ACCOUNT_PASSWORD(1,"账号密码");

        private int value;
        private String description;

        KEY_TYPE(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }
    }

    /**
     * 数据库连接方式
     */
    @Deprecated // 不建议使用 推荐使用  CommonEnumUtil.DATA_SOURCE_TYPE
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum DATA_SOURCE_TYPE {
        SOURCE_MARIA_DB(100, "MariaDB", "MariaDB 10.1","com.mysql.jdbc.Driver",3306,null),
        SOURCE_SQL_SERVER(200, "SQL Server", "SQL Server 2017","com.microsoft.sqlserver.jdbc.SQLServerDriver",1433,"dbo"),
        SOURCE_ORACLE(300, "Oracle", "Oralce 12C","oracle.jdbc.driver.OracleDriver",1521,null),
        SOURCE_POSTGRE_SQL(400, "PostgreSql", "PostgreSql 10.5","org.postgresql.Driver",5432,"public");

        private int value;
        private String code;
        private String description;
        private String driverClassName;
        private int defaultPort;
        private String defaultSchemaPattern;

        private DATA_SOURCE_TYPE (int value, String code, String description,String driverClassName,int port,String defaultSchemaPattern) {
            this.value = value;
            this.code = code;
            this.description = description;
            this.driverClassName = driverClassName;
            this.defaultPort = port;
            this.defaultSchemaPattern = defaultSchemaPattern;
        }

        public int getValue() {
            return value;
        }

        public String getCode() {
            return code;
        }

        public String getDescription() {
            return description;
        }

        public String getDriverClassName() {
            return driverClassName;
        }

        public int getDefaultPort() {
            return defaultPort;
        }

        public String getDefaultSchemaPattern() {
            return defaultSchemaPattern;
        }

        public static String valueOfCode(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].code;
                }
            }
            return tmp;
        }

        public static int codeOfValue(String code) {
            int tmp = 1;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].code.equals(code)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static BlockSoftSwitchEnumUtil.DATA_SOURCE_TYPE valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    return values()[i];
                }
            }
            return null;
        }

        public static String codeOfDescription(String code) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].code.equals(code)) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public String getJDBCUrl(String database,String host,Integer port){
            if(this.getValue() == SOURCE_MARIA_DB.getValue()){
                return getJDBCUrlMySQL(database,host,port);
            }else if(this.getValue() == SOURCE_ORACLE.getValue()){
                return getJDBCUrlOracle(database,host,port);
            }else if(this.getValue() == SOURCE_POSTGRE_SQL.getValue()){
                return getJDBCUrlPostgreSQL(database,host,port);
            }else if(this.getValue() == SOURCE_SQL_SERVER.getValue()){
                return getJDBCUrlSQLServer(database,host,port);
            }
            return null;
        }

        public static BlockSoftSwitchEnumUtil.DATA_SOURCE_TYPE getDataSourceURL(String databaseProductName){
            if(StringUtils.isNotBlank(databaseProductName)){
                if(databaseProductName.indexOf(":mysql:") != -1){
                    return SOURCE_MARIA_DB;
                }else if(databaseProductName.indexOf(":oracle:") != -1){
                    return SOURCE_ORACLE;
                }else if(databaseProductName.indexOf(":postgresql:") != -1){
                    return SOURCE_POSTGRE_SQL;
                }else if(databaseProductName.indexOf(":sqlserver:") != -1){
                    return SOURCE_SQL_SERVER;
                }
            }
            return null;
        }

        private String getJDBCUrlMySQL(String database,String host,Integer port){
            return "jdbc:mysql://"+host+":"+port+"/"+database+"?autoReconnect=true&useSSL=false&characterEncoding=utf-8";
        }

        private String getJDBCUrlOracle(String database,String host,Integer port){
            return "jdbc:oracle:thin:@"+host+":"+port+":"+database;
        }

        private String getJDBCUrlPostgreSQL(String database,String host,Integer port){
            return "jdbc:postgresql://"+host+":"+port+"/"+database;
        }

        private String getJDBCUrlSQLServer(String database,String host,Integer port){
            return "jdbc:sqlserver://" + host + ":" + port + ";database=" + database;
        }
    }

    /**
     * 参数值类型
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum PARAM_VALUE_TYPE{
        NUM(10,"数字"),
        STRING(20,"字符串"),
        BOOLEAN(30,"布尔"),
        MAP(40,"字典"),
        LIST(50,"列表"),
        JAVA_OBJECT(60,"Java Object"),
        JAVA_DYNAMIC_OBJECT(61,"Java Dynamic Object"),
        ARRAY(70,"数组");

        private int value;
        private String description;

        PARAM_VALUE_TYPE(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static PARAM_VALUE_TYPE valueOfValueStr(String value){
            PARAM_VALUE_TYPE result = PARAM_VALUE_TYPE.STRING;
            try {
                if(StringUtils.isNotBlank(value)){
                    for (int i = 0; i < values().length; i++) {
                        if (values()[i].value == Integer.parseInt(value)) {
                            return values()[i];
                        }
                    }
                }
            }catch (Exception e){
            }
            return result;
        }

        public static PARAM_VALUE_TYPE valueOf(int value){
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == value) {
                    return values()[i];
                }
            }
            return null;
        }
    }

    /**
     * 参数类型
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum PARAM_TYPE{
        OUT_PARAM(1,"出参"),
        IN_PARAM(2,"入参"),
        REQUEST_HEADER(3,"请求头");

        private int value;
        private String description;

        PARAM_TYPE(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }
    }

    /**
     * 适配方式
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum SUIT_METHOD{
        ACTIVE(1,"主动适配"),
        SCHEDULE(2,"定时调度");

        private int value;
        private String description;

        SUIT_METHOD(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }
    }

    /**
     * 数据库操作方式
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum DATABASE_OPERATE_TYPE{
        READ(1,"读取"),
        WRITE(2,"写入"),
        BATCH_WRITE(3,"批量写入");

        private int value;
        private String description;

        DATABASE_OPERATE_TYPE(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }
    }

    /**
     * 请求方式
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum REQUEST_METHOD{
        GET(1,"GET"),
        POST(2,"POST"),
        PUT(3,"PUT"),
        DELETE(4,"DELETE");

        private int value;
        private String description;

        REQUEST_METHOD(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }
    }

    /**
     * ftp传输编码
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum FTP_ENCODE {
        UTF8(10, "UTF-8", "UTF-8"),
        GBK(20, "GBK", "GBK"),
        ISO88591(30, "ISO-8859-1", "ISO-8859-1");

        private int value;
        private String encode;
        private String description;

        private FTP_ENCODE (int value,String encode, String description) {
            this.value = value;
            this.encode = encode;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getEncode() {
            return encode;
        }

        public String getDescription() {
            return description;
        }



        public static String valueOfCode(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].encode;
                }
            }
            return tmp;
        }

        public static int codeOfValue(String code) {
            int tmp = 1;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].encode.equals(code)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static FTP_ENCODE valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    return values()[i];
                }
            }
            return null;
        }
        public static String valueOfEncode(int value) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == value) {
                    tmp = values()[i].encode;
                }
            }
            return tmp;
        }

        public static String codeOfDescription(String code) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].encode.equals(code)) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }
    }

    /**
     * 适配报文类型
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum SUIT_DATA_TYPE {
        XML(10, "XML"),
        JSON(20,  "JSON");

        private int value;
        private String description;

        private SUIT_DATA_TYPE (int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static SUIT_DATA_TYPE valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    return values()[i];
                }
            }
            return null;
        }

    }

    /**
     * 适配报文处理状态
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum SUIT_PROCESS_STATUS {
        UNPROCESSED(10, "未处理"),
        PROCESSING(20,  "处理中"),
        PROCESS(30,  "已处理"),
        PROCESS_FAIL(40,  "处理失败");

        private int value;
        private String description;

        private SUIT_PROCESS_STATUS (int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static SUIT_PROCESS_STATUS valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    return values()[i];
                }
            }
            return null;
        }
    }

    /**
     * 长数据关联数据类型
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum REF_DATA_TYPE {
        SUIT_MESSAGE(10, "适配信息"),
        REQUEST_ORGIN_PARAM(20,  "请求原始参数"),
        ORIGINAL_MESSAGE(30,  "原始报文"),
        CONVERTED_MESSAGE(40,  "转换报文"),
        SUIT_SEND_MESSAGE(50,  "适配发送报文"),
        PROCESS_RESULT(60,  "处理结果");

        private int value;
        private String description;

        private REF_DATA_TYPE (int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static REF_DATA_TYPE valueOf(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    return values()[i];
                }
            }
            return null;
        }

    }

    /**
     * ftp连接模式
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum FTP_CONNECTION_MODE {
        LOCAL_ACTIVE_MODE(10,  "本地主动模式"),
        LOCAL_PASSIVE_MODE(20, "本地被动模式");
//        REMOTE_ACTIVE_MODE(30, "远程主动模式"),
//        REMOTE_PASSIVE_MODE(40, "远程被动模式");

        private final int value;
        private final String description;

        FTP_CONNECTION_MODE(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static FTP_CONNECTION_MODE valueOf(int val) {
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    return values()[i];
                }
            }
            return FTP_CONNECTION_MODE.LOCAL_ACTIVE_MODE;
        }
    }

    /**
     * 脚本类型
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum BS_SCRIPT_TYPE {
        MESSAGE_PROCESS(10, "报文处理","可用参数:transData,orginData");

        private int value;
        private String description;
        private String scriptRule;

        private BS_SCRIPT_TYPE (int value, String description,String scriptRule) {
            this.value = value;
            this.description = description;
            this.scriptRule = scriptRule;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }
        public String getScriptRule() {
            return scriptRule;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static BS_SCRIPT_TYPE valueOf(int val) {
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    return values()[i];
                }
            }
            return null;
        }

    }

    /**
     * 脚本语言
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum BS_SCRIPT_LANGUAGE {
//        SPEL(10, "Spring表达式语言(SpEL)"),
        JAVASCRIPT(20, "JavaScript(JS)");

        private int value;
        private String description;

        private BS_SCRIPT_LANGUAGE (int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static BS_SCRIPT_LANGUAGE valueOf(int val) {
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    return values()[i];
                }
            }
            return null;
        }

    }

    /**
     * 脚本执行方式
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum BS_SCRIPT_EXECUTE_METHOD {
        EXECUTE_SCRIPT(10, "执行脚本"),
        EXECUTE_METHOD(20, "执行方法"),
        EXECUTE_OBJECT_METHOD(30, "执行对象方法");

        private int value;
        private String description;

        private BS_SCRIPT_EXECUTE_METHOD (int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static BS_SCRIPT_EXECUTE_METHOD valueOf(int val) {
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    return values()[i];
                }
            }
            return null;
        }

    }

    /**
     * 适配重试方法
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum BS_SUIT_RETRY_METHOD {
        RESET_MESSAGE_STATE(10, "重置报文状态"),
        RE_EXECUTE(20, "重新执行");

        private int value;
        private String description;

        private BS_SUIT_RETRY_METHOD (int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static BS_SUIT_RETRY_METHOD valueOf(int val) {
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    return values()[i];
                }
            }
            return null;
        }

    }

    /**
     * 适配重试方法
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum BS_SUIT_RETRY_STATUS {
        NOT_RETRY(10, "未重试"),
        RETRY(20, "已重试");

        private int value;
        private String description;

        private BS_SUIT_RETRY_STATUS (int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public static String valueOfDescription(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }

        public static BS_SUIT_RETRY_STATUS valueOf(int val) {
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    return values()[i];
                }
            }
            return null;
        }

    }

}
