I have the following request.
@Data
public class ProductRequest {
@NotEmpty
private String code;
@NotEmpty
private String name;
}
I use this request for 2 different methods and both of them use only one field, not need the other field. Let's say that methodA using code
and methodB using name
field in this request (not need other field). So, in this scene I think a solution for using the same request for both methods, instead of creating 2 separate request. So, is there anything that make it possible one of the field is not null? I am also not sure if it solves my problem, because in this scene request will not know which property should not be null. Any idea to fix this problem?