win.doyto.query.web.response.JsonResponse Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of doyto-query-web Show documentation
Show all versions of doyto-query-web Show documentation
The web layer integrate with Spring Web
// Generated by delombok at Sat Apr 04 14:54:36 CST 2020
package win.doyto.query.web.response;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* 返回给移动客户端的JSON对象的结构
*
* @author Yuanzhen on 2015-09-07.
*/
public class JsonResponse implements ErrorCode {
@java.lang.SuppressWarnings("all")
@lombok.Generated
private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(JsonResponse.class);
private Integer code = 0;
private String message = "ok";
private T data;
private Map> errors;
public JsonResponse(int code, String message) {
this.code = code;
this.message = message;
}
@Override
public void addError(String fieldName, String message) {
final Map> messages = internalGetErrors();
List fieldMessages = messages.computeIfAbsent(fieldName, k -> new ArrayList<>());
fieldMessages.add(message);
}
private synchronized Map> internalGetErrors() {
if (errors == null) {
errors = new ConcurrentHashMap<>();
}
return errors;
}
@java.lang.SuppressWarnings("all")
@lombok.Generated
public Integer getCode() {
return this.code;
}
@java.lang.SuppressWarnings("all")
@lombok.Generated
public String getMessage() {
return this.message;
}
@java.lang.SuppressWarnings("all")
@lombok.Generated
public T getData() {
return this.data;
}
@java.lang.SuppressWarnings("all")
@lombok.Generated
public Map> getErrors() {
return this.errors;
}
@java.lang.SuppressWarnings("all")
@lombok.Generated
public JsonResponse setCode(final Integer code) {
this.code = code;
return this;
}
@java.lang.SuppressWarnings("all")
@lombok.Generated
public JsonResponse setMessage(final String message) {
this.message = message;
return this;
}
@java.lang.SuppressWarnings("all")
@lombok.Generated
public JsonResponse setData(final T data) {
this.data = data;
return this;
}
@java.lang.SuppressWarnings("all")
@lombok.Generated
public JsonResponse setErrors(final Map> errors) {
this.errors = errors;
return this;
}
@java.lang.SuppressWarnings("all")
@lombok.Generated
public JsonResponse() {
}
}