Quoting Rickard Öberg <[email protected]>:

One problem is that I don't think there's really any difference between them, with regard to the implementation.

Yeah, that's why I suggested other type of syntax right after that :)

The Constraint interface covers them all. I suppose what we could do is have different annotations on the annotations, i.e.
@ConstraintDeclaration
@Retention( RetentionPolicy.RUNTIME )
@Constraints( MaxLengthConstraint.class )
public @interface MaxLength
{
    int value();
}
for parameters and returnvalues, and then:
@MethodConstraintDeclaration
@Retention( RetentionPolicy.RUNTIME )
@Constraints( AssignedConstraint.class )
public @interface Assigned
{
    boolean value();
}

Which would lead to:
@Optional @Assigned(false)
void assignTo(User user);

where @Optional refers to return-value (as it doesn't make sense to say "Optional" on the method), and @Assigned is clearly for the method, and yet the implementation AssignedConstraint simply implements Constraint<Assigned,Assignable>.


Would that could cause any ambiguity in case return-value constraint takes some parameters too?

By the way, as a nit-picking note, I just realized that that specific example doesn't make sense - applying return-value constraint on a void method. :)


_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev

Reply via email to