Last active
August 29, 2015 14:13
-
-
Save dynamokaj/cb0c0569311d9d15ee40 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ResponseDto<T> { | |
private Status status; | |
private String message; | |
private T object; //your bean or entity object | |
public Status getStatus() { | |
return status; | |
} | |
public void setStatus(Status status) { | |
this.status = status; | |
} | |
public String getMessage() { | |
return message; | |
} | |
public void setMessage(String message) { | |
this.message = message; | |
} | |
public T getObject() { | |
return object; | |
} | |
public void setObject(T object) { | |
this.object = object; | |
} | |
public RestResponseDto toRestResponse() { | |
RestResponseDto r = new RestResponseDto(); | |
r.setStatus(status); | |
r.setMessage(message); | |
r.setObject(object); | |
return r; | |
} | |
/** | |
* The actual reponse returned by the endpoints, since Cloud Endpoints does not supports generics. | |
*/ | |
public class RestResponseDto { | |
private Status status; | |
private String message; | |
private Object object; | |
public Status getStatus() { | |
return status; | |
} | |
public void setStatus(Status status) { | |
this.status = status; | |
} | |
public String getMessage() { | |
return message; | |
} | |
public void setMessage(String message) { | |
this.message = message; | |
} | |
public Object getObject() { | |
return object; | |
} | |
public void setObject(Object object) { | |
this.object = object; | |
} | |
} | |
/** | |
* This status of the overall response. | |
*/ | |
public enum Status { | |
SUCCESS, ERROR | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment