package com.nanjing.water.common.enums; import java.util.Arrays; /** * tokenå˜æ”¾åœ°æ–¹ 枚举 * @author linliu * @date 2019-06-04 */ public enum ERequestTokenFrom { /** * token从 headers ä¼ è¾“ */ HEADERS("headers", 1), /** * token从 urls ä¼ è¾“ */ URLS("urls", 2); private String desc;//枚举æè¿° private int value;//枚举值 public int getValue() { return value; } public String getDesc() { return desc; } /** * æž„é€ æ–¹æ³• * @param desc 枚举æè¿° * @param value 枚举值 */ ERequestTokenFrom(String desc, int value) { this.desc = desc; this.value = value; } /** * æ ¹æ®å€¼èŽ·å–æžšä¸¾ * * @param value 枚举值 * @return */ public static ERequestTokenFrom getByValue(int value) { return Arrays.stream(ERequestTokenFrom.values()) .filter(e -> e.getValue() == value) .findFirst() .orElse(null); } @Override public String toString() { return "ERequestTokenFrom{" + "desc='" + desc + '\'' + ", value=" + value + '}'; } }