package cn.estsh.i3plus.pojo.wms.dbinterface;

import com.fasterxml.jackson.annotation.JsonFormat;

public class WmsInterfaceEnumUtil {

    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum DIRECTION_TYPE {
        SAP2WMS(10, "SAP2WMS", "SAP --> WMS"),
        WMS2SAP(20, "WMS2SAP", "WMS --> SAP"),
        MES2WMS(30, "MES2WMS", "MES --> WMS"),
        WMS2MES(40, "WMS2MES", "WMS --> MES"),
        SWEB2WMS(50, "SWEB2WMS", "SWEB --> WMS"),
        WMS2SWEB(50, "WMS2SWEB", "WMS --> SWEB"),
        SAP2SWEB(50, "SAP2SWEB", "SAP --> SWEB");

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

        DIRECTION_TYPE() {
        }

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

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public String getName() {
            return name;
        }

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

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

        /**
         * -1 不在范围内
         * @param desc
         * @return
         */
        public static int descOf(String desc) {
            int tmp = -1;
            for (int i = 0; i < values().length; i++) {
                if (values()[i].description.equals(desc)) {
                    tmp = values()[i].value;
                }
            }
            return tmp;
        }
    }
}
