Let us say that we have a class from API which has some fields, of which some are made mandatory using @NotNull
annotation, like below:
class SomeAPIClass {
private String field1;
private String field2;
@NotNull
public String getField1() {
return field1;
}
public String getField2() {
return field2;
}
public void setField1(String field1) {
this.field1 = field1;
}
public void setField2(String field2) {
this.field2 = field2;
}
}
Now we have extended this class and added some of our own attribute field3
, however, we do not wish to use field1
(which is mandatory).
class SomeCustomClass extends SomeAPIClass {
private String field3;
public String getField3() {
return field3;
}
public void setField3(String field3) {
this.field1 = field1;
}
}
But as field1
is defined as mandatory field in API class, which cannot be touched/changed there, it is failing validation. Is there any way I can get rid of that annotation in child class SomeCustomClass
?