[bv-dev] Spec question on ContainerElementTypeDescriptor

Matt Benson mbenson at apache.org
Thu Jun 15 11:38:29 EDT 2017

The various descriptor types return constraint information from the
entire hierarchy by default. However, in thinking about this I quickly
encountered a puzzle which I cannot solve using the current version of
the specification. Consider:

public interface User {
  Set<@NotEmpty String> getRoles();

public class Roles implements Set<String> {

public class UserImpl implements User {
  public Roles getRoles();

What should the metadata of UserImpl provide? The Iterable value
extractor is applicable to Roles, but because the return value of the
getter has been narrowed, there is no type parameter at this point in
the hierarchy. It seems strange for a PropertyDescriptor of type Roles
to return a ContainerElementTypeDescriptor with index 0. This example
would AFAICT apply to e.g. javafx StringProperty as well, so it's
probably a question we need to resolve, unless I have missed something
that should be obvious. I think this could be solved if the CETD were
to explicitly specify the type with which its argument index is
associated. The alternative would be to require a custom
ValueExtractor? This seems cumbersome and unnecessary.


More information about the beanvalidation-dev mailing list