工具类
程序员文章站
2022-03-03 10:26:35
...
工具类:
- Result
package com.test.user.common;
public class Result {
private final static String SUCCESS_CODE = "200";
private final static String ERROR_CODE = "400";
private String code;
private Object data;
private String msg;
private Result() {
}
public static Result success() {
return new Result().setCode(SUCCESS_CODE);
}
public static Result success(Object object) {
return new Result().setCode(SUCCESS_CODE).setData(object);
}
public static Result error(String msg) {
return new Result().setMsg(msg).setCode(ERROR_CODE);
}
public String getCode() {
return code;
}
public Result setCode(String code) {
this.code = code;
return this;
}
public Object getData() {
return data;
}
public Result setData(Object data) {
this.data = data;
return this;
}
public String getMsg() {
return msg;
}
public Result setMsg(String msg) {
this.msg = msg;
return this;
}
}
- BlankUtil
package com.test.util;
import java.util.List;
import java.util.Map;
public abstract class BlankUtil {
private BlankUtil(){
}
public static boolean IsBlank(Object obj){
if(obj == null)
return true;
if(obj instanceof List)
if(((List)obj).size()==0)
return true;
if(obj instanceof Map)
if(((Map)obj).size()==0)
return true;
if(obj instanceof String)
if(((String)obj).trim().length()==0)
return true;
return false;
}
public static boolean IsNotBlank(Object obj){
return !IsBlank(obj);
}
}
上一篇: JAVA XML文件转MAP
下一篇: 文件选择器