public class Address {
@NotEmpty @Max(50)
private String street1;
@Max(50)
private String street2;
@Max(9) @NotNull
private String zipcode;
...
}and then be able to say something like:
public class Order {
@Valid @NotNull private Address delivery;
}The implications of something like this go beyond mere validation. IMHO it si an elegant solution that if built properly will improve the DRYness of the code across all layers of any java application.
This is the intention behind jsr-303. .