枚举类的正确打开方式

package com.feng.zshop.common.constant;

import org.springframework.util.StringUtils;

/**
 * 返回码
 * @author Lee
 * @date 2019/2/11
 */
public enum ResponseCodeEnum {

    SUCCESS(1),
    FAILURE(0);

    private int value;

    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }

    ResponseCodeEnum(int value){
        this.value = value;
    }

   public static ResponseCodeEnum getEnum(String enumStr){
       ResponseCodeEnum[] values = values();
       for (ResponseCodeEnum value : values) {
           if (!StringUtils.isEmpty(enumStr) && value.toString().equals(enumStr)) {
               return value;
           }
       }
       return null;
   }

}

 

你可能感兴趣的:(problem)