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 ModelEnumUtil {

    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum COMMON_TREE_TYPE{

        TYPE_ORGANIZE(1,"组织","SysOrganize"),
        TYPE_DEPARTMENT(2,"部门","SysDepartment"),
        ;

        private int value;
        private String name;
        private String description;

        COMMON_TREE_TYPE() {
        }

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

        public int getValue() {
            return value;
        }

        public String getName() {
            return name;
        }

        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].name;
                }
            }
            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 String codeOfDescription(String code) {
            String tmp = null;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].name.equals(code)) {
                    tmp = values()[i].description;
                }
            }
            return tmp;
        }
    }
}
