package com.yuchen.saas.integration.hik.isc.enmus;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.nest.springwrap.core.tool.utils.Func;

import java.util.Objects;

/**
 * @author
 * @create 2020/10/17 14:45
 */
public class CameraDeviceEnum {



    /**
     * 区域类型 1:重点区域；2：其他区域"
     */
    @Getter
    @AllArgsConstructor
    public enum AreaTypeEnum {
        FOCUS(1, "重点区域"),

        OTHER(2, "其他区域"),


        ;

        private final int code;
        private final String desc;

        public static String getDescByCode(Integer code) {
            if (Objects.isNull(code)) {
                return null;
            }
            CameraDeviceEnum.AreaTypeEnum[] enumArray = CameraDeviceEnum.AreaTypeEnum.values();
            for (CameraDeviceEnum.AreaTypeEnum e : enumArray) {
                if (e.getCode() == code) {
                    return e.getDesc();
                }
            }
            return "";
        }

        public static Integer getCodeByDesc(String desc) {
            if (Objects.isNull(desc)) {
                return null;
            }
            CameraDeviceEnum.AreaTypeEnum[] enumArray = CameraDeviceEnum.AreaTypeEnum.values();
            for (CameraDeviceEnum.AreaTypeEnum e : enumArray) {
                if (Func.equalsSafe(desc,e.getDesc()) ) {
                    return e.getCode();
                }
            }
            return null;
        }
    }



}
