Hi all.
I use @AssertTrue
annotation to ensure the execution of a method that sets some default values (always returns true). These set values are validated as @NotEmpty
(these are Strings). So I need to guarantee that method annotated with @AssertTrue
is executed strictly before that fields annotated with @NotEmpty
.
Simplified code example (not included Hibernate annotations):
public class MyClass {
@NotEmpty
private String myField = null;
@SuppressWarnings("unused")
@AssertTrue
private boolean fillDefaultValues() {
if (this.myField == null) {
this.myField = "default value";
}
return true;
}
}