I have a class as show below:-
@Getter
@Setter
@NoArgsConstructor
public class Response extends ResponseMessage {
@JsonProperty("ResponseDto")
private myDTo myDto;
@JsonProperty("revId")
private Long revisionId;
@JsonProperty("modelId")
private Long model;
public Response(HttpStatus status, String message) {
super(status, message);
}
public Response(HttpStatus status, String message, Long revisionId) {
super(status, message);
this.revisionId = revisionId;
}
public Response(HttpStatus status, String message, Long revisionId, Long modelId) {
super(status, message);
this.revisionId = revisionId;
this.model = modelId;
}
public Response(HttpStatus status, String message, myDTo myDto) {
super(status, message);
this.myDto = myDto;
}
}
Now when i am return the Response class as response as shown below:-
return new Response(HttpStatus.OK,"done",123);
It return the response json as:-
{
"revId":123,
"status":"OK",
"modelId":null,
"message":"done"
}
but the want the response to be depend on the constructor which is being called. which in this case should be :-
{
"revId":123,
"status":"OK",
"message":"done"
}
Any help will be highly appreciated!