2020-03-26 枚举类的 .VALUES() 方法

2020-03-26  本文已影响0人  很菜的花椰菜

https://blog.csdn.net/qq_26676207/article/details/80405497

 if(AccessTokenStatusEnum.valueOfByValue(tokenDO.getAccessTokenStatus()) != AccessTokenStatusEnum.VALID){
            logger.info("{},{},token is invalid ",tokenDO.getAccessTokenStatus(),tokenDO.getAuthRefreshToken());
            throw new OauthException(OauthErrorCodeEnum.ILLEGAL_ARGUMENT,"token is invalid");
        }

还有就是 枚举类中的 Valueof的使用


image.png
public class Test {

    public static void main(String[] args) {
        //下面两个东西是一样的
        ResultEnum resultEnum = ResultEnum.valueOf("EXPORT_ULTRALIMIT");
        ResultEnum resultEnum1 = ResultEnum.valueOf(ResultEnum.class,"EXPORT_ULTRALIMIT");
        System.out.println(resultEnum1.getCode());
        System.out.println(resultEnum1.getDesc());
        System.out.println(JSON.toJSONString(resultEnum1));
    }
}
上一篇 下一篇

猜你喜欢

热点阅读