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

import com.fasterxml.jackson.annotation.JsonFormat;

/**
 * @Description : Model Pojo 枚举
 * @Reference :
 * @Author : Adair Peng
 * @CreateDate : 2018-11-21 15:50
 * @Modify:
 **/
public class MdmEnumUtil {

    /**
     * 操作类型
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum MDM_OPERATE_TYPE {
        INSERT(1,  "新增"),
        UPDATE(2,  "修改");

        private int value;
        private String description;

        private MDM_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;
        }

        public static MdmEnumUtil.MDM_OPERATE_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;
        }
    }

    /**
     * hql实体类型
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum HQL_ENTITY_TYPE {
        MASTER(1, "master", "主数据"),
        BUSI(2, "busi", "业务数据");

        private int value;
        private String alias;
        private String description;

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

        public int getValue() {
            return value;
        }

        public String getAlias() {
            return alias;
        }

        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 String valueOfAlias(int val) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].value == val) {
                    tmp = values()[i].alias;
                }
            }
            return tmp;
        }

        public static MdmEnumUtil.HQL_ENTITY_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;
        }
    }

    /**
     * mdm
     */
    public enum MDM_SYNC_TYPE{
        INSERT(1,  "新增"),
        UPDATE(2,  "修改"),
        DELETE(3,  "删除");

        private int value;
        private String description;

        private MDM_SYNC_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 MdmEnumUtil.MDM_SYNC_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;
        }
    }

}
