I have a client library in which I am making http remote calls to my rest service and then I am returning List<DataResponse>
back to the customer who is calling our library with the response I am getting from my REST service along with any errors if there are any wrapped around DataResponse
object.
public class DataResponse {
private final String response;
private final boolean isLink;
private final TypeOfId idType;
private final long ctime;
private final long lmd;
private final String maskInfo;
// below are for error stuff
private final ErrorCode error;
private final StatusCode status;
// constructors and getters here
}
Here is my ErrorCode
enum class:
public enum ErrorCode {
// enum values
private final int code;
private final String status;
private final String description;
// constructors and getters
}
And here is my StatusCode
enum class:
public enum StatusCode {
SUCCESS, FAILURE;
}
As you can see in my DataResponse
class I have lot of fields so basis on that I have a very long constructor and everytime when I make a DataResponse
object I have a big line with new DataResponse(.......)
. In future I might have more fields but for now I only have these fields.
Is there any better way I can use to make a DataResponse
object and then return back List<DataResponse>
from my library?