I am currently making a service in which there are lots of public API's. And the response and request objects overlap a lot. So, I was thinking that is there a way by which we can generalise the pojo creation for the request/response objects. Sometimes the response object is identical to the request object with one or two extra fields.
Let me give you an example.
@Data
public class Request {
private A objA;
private B objB;
}
@Data
public class Response {
private A objA;
private B objB;
private C objC;
}
@Data
public class A {
private D objD;
}
@Data
public class B {
private String sB;
private E obje;
}
@Data
public class C {
private String sC;
}
Similary, D and E are pojos as well. The thing is that there is a lot of similarity(overlapping fields) in request/response objects.