@Override public <A extends Annotation> ConstraintDefinitionContext<A> constraintDefinition(Class<A> annotationClass) { Contracts.assertNotNull( annotationClass, MESSAGES.annotationTypeMustNotBeNull() ); Contracts.assertTrue( annotationClass.isAnnotationPresent( Constraint.class ), MESSAGES.annotationTypeMustBeAnnotatedWithConstraint() ); if ( definedConstraints.contains( annotationClass ) ) { // Fail fast for easy-to-detect definition conflicts; other conflicts are handled in ValidatorFactoryImpl throw log.getConstraintHasAlreadyBeenConfiguredViaProgrammaticApiException( annotationClass ); } ConstraintDefinitionContextImpl<A> constraintContext = new ConstraintDefinitionContextImpl<A>( this, annotationClass ); constraintContexts.add( constraintContext ); definedConstraints.add( annotationClass ); return constraintContext; }
@Override public <A extends Annotation> ConstraintDefinitionContext<A> constraintDefinition(Class<A> annotationClass) { Contracts.assertNotNull( annotationClass, MESSAGES.annotationTypeMustNotBeNull() ); Contracts.assertTrue( annotationClass.isAnnotationPresent( Constraint.class ), MESSAGES.annotationTypeMustBeAnnotatedWithConstraint() ); if ( definedConstraints.contains( annotationClass ) ) { // Fail fast for easy-to-detect definition conflicts; other conflicts are handled in ValidatorFactoryImpl throw LOG.getConstraintHasAlreadyBeenConfiguredViaProgrammaticApiException( annotationClass ); } ConstraintDefinitionContextImpl<A> constraintContext = new ConstraintDefinitionContextImpl<>( this, annotationClass ); constraintContexts.add( constraintContext ); definedConstraints.add( annotationClass ); return constraintContext; }