package com.lunhan.xxx.common.enums; import java.util.Arrays; /** * 水平位置 枚举 */ public enum EHorizontalLocation { /** * 靠左 */ LEFT("LEFT", 1), /** * 居中 */ CENTRE("CENTRE", 2), /** * 靠右 */ RIGHT("RIGHT", 3); private String desc;//枚举描述 private int value;//枚举值 public int getValue() { return value; } public String getDesc() { return desc; } /** * 构造方法 * @param desc 枚举描述 * @param value 枚举值 */ EHorizontalLocation(String desc, int value) { this.desc = desc; this.value = value; } /** * 根据值获取枚举 * * @param value 枚举值 * @return */ public static EHorizontalLocation getByValue(int value) { return Arrays.stream(EHorizontalLocation.values()) .filter(e -> e.getValue() == value) .findFirst() .orElse(null); } @Override public String toString() { return "EHorizontalLocation{" + "desc='" + desc + '\'' + ", value=" + value + '}'; } }