|
Ok, so what would be needed for option #2.
-
New annotation @UnwrapValidationValue
-
We probably need some sort of interface as Gunnar Morling has suggested
public interface ValidationValueUnwrapper {
Object getValidatedValue(Object source);
Type getDeclaredType(Type sourceType);
}
-
ValidationValueUnwrapper would need to be registered, for example in HibernateValidatorConfiguration by adding something like addValidationValueUnwrapper method. We might also need an accept(Type sourceType) method which is called first to determine if a given unwrapper can process a give type.
-
During validation each constrained object would then be passed through the list of unwrappers prior to validation
about the annotation inside the ParameterizedType (supported in Java 8), that may not be too intuitive for developers
Why do think it would not be intuitive?
|