I have old POJO with valid annotation:
public class SomeData {
@NotNull(message = "Data not be null")
private String data;
public FormData(String data) {
this.data = data;
}
public String getData() {
return data;
}
public String setData(String data) {
this.data = data
}
}
But know I have records
public record SomeData(String data) {}
How I can add annotation in records?
You can do like that:
public record SomeData(@NotNull(message = "Data not be null") String data) {}