package com.fengdu.gas.common.enums; import java.util.Arrays; import java.util.Objects; public enum EFacilityState { NO("停止", 0), YES("运行", 1), ONE("一级报警", 2), TWO("二级报警",3) ; private String desc;//枚举描述 private Integer value;//枚举值 public Integer getValue() { return value; } public String getDesc() { return desc; } /** * 构造方法 * @param desc 枚举描述 * @param value 枚举值 */ EFacilityState(String desc, Integer value) { this.desc = desc; this.value = value; } /** * 根据值获取枚举 * * @param value 枚举值 * @return */ public static EFacilityState getByValue(Integer value) { return Arrays.stream(EFacilityState.values()) .filter(e -> Objects.equals(e.getValue(), value)) .findFirst() .orElse(null); } @Override public String toString() { return "EFacilityState{" + "desc='" + desc + '\'' + ", value=" + value + '}'; } }