return new ArcResponse<Product>(HttpStatus.CREATED.value(), "创建成功", product);
如果让我写,我会这么写。用object代替泛型T
public class ArcResponse{
public ArcResponse(int httpStatus,String msg,Object data){//用object来接收数据,应该是多了强制类型转化
this.data = data;
meta = new meta();
}
}
public class ArcResponse<T> { private Meta meta; private T data; public ArcResponse() { } public ArcResponse(Meta meta, T data) { this.meta = meta; this.data = data; } public ArcResponse(Integer code, String message) { this.meta = new Meta(code, message); this.data = (T)new Object(); } public ArcResponse(Integer code, String message, T data) { this.meta = new Meta(code, message); this.data = data; } public Meta getMeta() { return meta; } public void setMeta(Meta meta) { this.meta = meta; } public T getData() { return data; } public void setData(T data) { this.data = data; } }