我有一个问题呀,老师是通过resultUtil,来实现的确实是没有问题,但是如果我想直接在Result中完成应该怎么处理呢?
package com.wang.common;
import java.io.Serializable;
public class Result<T> implements Serializable {
private Integer code;
private String message;
private T data;
private Result(Integer code,String message){
this.code = code;
this.message = message;
}
private Result(T data){
this.code = ResultEnum.SUCCESS.getCode();
this.message = ResultEnum.SUCCESS.getMessage();
this.data = data;
}
private Integer getCode() {
return code;
}
private void setCode(Integer code) {
this.code = code;
}
private String getMessage() {
return message;
}
private void setMessage(String message) {
this.message = message;
}
private T getData() {
return data;
}
private void setData(T data) {
this.data = data;
}
public static Result error(Integer code,String message){
return new Result(code,message);
}
}
这样直接调用Result.error报类型转换的错误,应该作何处理呢?请老师赐教,感激不尽