package com.lunhan.xxx.common.enums; import java.util.Arrays; /** * 垂直位置 枚举 */ public enum EVerticalLocation { /** * 靠顶端 */ TOP("TOP", 1), /** * 居中 */ MIDDLE("MIDDLE", 2), /** * 靠底部 */ BOTTOM("BOTTOM", 3); private String desc;//枚举描述 private int value;//枚举值 public int getValue() { return value; } public String getDesc() { return desc; } /** * 构造方法 * @param desc 枚举描述 * @param value 枚举值 */ EVerticalLocation(String desc, int value) { this.desc = desc; this.value = value; } /** * 根据值获取枚举 * * @param value 枚举值 * @return */ public static EVerticalLocation getByValue(int value) { return Arrays.stream(EVerticalLocation.values()) .filter(e -> e.getValue() == value) .findFirst() .orElse(null); } @Override public String toString() { return "EVerticalLocation{" + "desc='" + desc + '\'' + ", value=" + value + '}'; } }