private <T> boolean mainConstraintNeedsEvaluation(ValidationContext<T> executionContext, Set<ConstraintViolation<T>> constraintViolations) { // we are dealing with a composing constraint with no validator for the main constraint if ( !descriptor.getComposingConstraints().isEmpty() && descriptor.getMatchingConstraintValidatorClasses() .isEmpty() ) { return false; } // report as single violation and there is already a violation if ( descriptor.isReportAsSingleViolation() && descriptor.getCompositionType() == AND && !constraintViolations.isEmpty() ) { return false; } // explicit fail fast mode if ( executionContext.isFailFastModeEnabled() && !constraintViolations.isEmpty() ) { return false; } return true; }
/** * @return {@code} true if the current constraint should be reported as single violation, {@code false otherwise}. * When using negation, we only report the single top-level violation, as * it is hard, especially for ALL_FALSE to give meaningful reports */ private boolean reportAsSingleViolation() { return getDescriptor().isReportAsSingleViolation() || getDescriptor().getCompositionType() == ALL_FALSE; }
private <T> boolean mainConstraintNeedsEvaluation(ValidationContext<T> executionContext, Set<ConstraintViolation<T>> constraintViolations) { // we are dealing with a composing constraint with no validator for the main constraint if ( !descriptor.getComposingConstraints().isEmpty() && descriptor.getMatchingConstraintValidatorDescriptors().isEmpty() ) { return false; } if ( constraintViolations.isEmpty() ) { return true; } // report as single violation and there is already a violation if ( descriptor.isReportAsSingleViolation() && descriptor.getCompositionType() == AND ) { return false; } // explicit fail fast mode if ( executionContext.isFailFastModeEnabled() ) { return false; } return true; }
/** * @return {@code} true if the current constraint should be reported as single violation, {@code false otherwise}. * When using negation, we only report the single top-level violation, as * it is hard, especially for ALL_FALSE to give meaningful reports */ private boolean reportAsSingleViolation() { return getDescriptor().isReportAsSingleViolation() || getDescriptor().getCompositionType() == ALL_FALSE; }
private boolean passesCompositionTypeRequirement(Set<?> constraintViolations, CompositionResult compositionResult) { CompositionType compositionType = getDescriptor().getCompositionType(); boolean passedValidation = false; switch ( compositionType ) { case OR: passedValidation = compositionResult.isAtLeastOneTrue(); break; case AND: passedValidation = compositionResult.isAllTrue(); break; case ALL_FALSE: passedValidation = !compositionResult.isAtLeastOneTrue(); break; } assert ( !passedValidation || !( compositionType == AND ) || constraintViolations.isEmpty() ); if ( passedValidation ) { constraintViolations.clear(); } return passedValidation; }
private boolean passesCompositionTypeRequirement(Set<?> constraintViolations, CompositionResult compositionResult) { CompositionType compositionType = getDescriptor().getCompositionType(); boolean passedValidation = false; switch ( compositionType ) { case OR: passedValidation = compositionResult.isAtLeastOneTrue(); break; case AND: passedValidation = compositionResult.isAllTrue(); break; case ALL_FALSE: passedValidation = !compositionResult.isAtLeastOneTrue(); break; } assert ( !passedValidation || !( compositionType == AND ) || constraintViolations.isEmpty() ); if ( passedValidation ) { constraintViolations.clear(); } return passedValidation; }
compositionResult.setAtLeastOneTrue( true ); if ( descriptor.getCompositionType() == OR ) { break; if ( descriptor.getCompositionType() == AND && ( executionContext.isFailFastModeEnabled() || descriptor.isReportAsSingleViolation() ) ) { break;
compositionResult.setAtLeastOneTrue( true ); if ( descriptor.getCompositionType() == OR ) { break; if ( descriptor.getCompositionType() == AND && ( executionContext.isFailFastModeEnabled() || descriptor.isReportAsSingleViolation() ) ) { break;