Hi,
I am wondering about constraint initialization, especially in the context of composite constraints. The current interface for
Constraint looks like this:
Code:
public interface Constraint<A extends Annotation> {
void initialize(A constraintAnnotation);
boolean isValid(Object object, ConstraintContext constraintContext);
}
Effectively you are passing the constraint annotation itself into
initialize(). This works fine for constraints defined on beans. However, in the case of composing constraints it makes things harder since parameters can be overridden. Woudln't it be better to pass a map into
initalize()?
Another reason why I think this is useful is that one could in this case instantiate and initialize a constraint using
ConstraintDescriptor information only (
ConstraintDescriptor contains
getConstraintClass() and
getParameters() which returns the parameters as map). This is otherwise not possible.
Any comments?
--Hardy