I have a class with variables I don't want it to be null or empty. Is there a way to use Lombok builder to set the property? I can use @NonNull
but I won't be able to verify if it is empty or not. Obviously the other option is to write my own builder which does all these checks. For example:
class Person {
@NonNull
private String firstName;
@NonNull
private String lastName;
public static class PersonBuilder() {
// .
// .
// .
public Person build() {
//do checks for empty etc and return object
}
}
}