package com.lunhan.water.entity.enums; import java.util.Arrays; import java.util.Objects; public enum EPaymentChannel { /** * 微信=10010, */ WE_CHAT("微信", 10010), /** * 支付宝=10020, */ ALI_PAY("支付宝", 10020), ; /** * 枚举描述 */ private String desc; /** * 枚举值 */ private Integer value; public Integer getValue() { return value; } public String getDesc() { return desc; } /** * 构造方法 * @param desc 枚举描述 * @param value 枚举值 */ EPaymentChannel(String desc, Integer value) { this.desc = desc; this.value = value; } /** * 根据值获取枚举 * * @param value 枚举值 * @return */ public static EPaymentChannel getByValue(Integer value) { return Arrays.stream(EPaymentChannel.values()) .filter(e -> Objects.equals(e.getValue(), value)) .findAny() .orElse(null); } @Override public String toString() { return "EPaymentChannel{" + "desc='" + desc + '\'' + ", value=" + value + '}'; } }