枚举类型
定义
public enum ActionCodeEnum{
CREATE("create"),
UPDATE("update"),
QUERY("query"),
DELETE("delete");
private String code;
private ActionCodeEnum(String code){
this.code = code;
}
}
调用
public class UseEnum{
public boolean isCreate(ActionCodeEnum actionCodeEnum){
return actionCodeEnum == ActionCodeEnum.CREATE;
}
}
使用
public class Test{
public static void main(){
UseEnum useEnum = new UseEnum();
useEnum.isCreate(ActionCodeEnum.UPDATE);
}
}
这里的ActionCodeEnum.UPDATE == "update"