Top Description Inners Fields Constructors Methods
org.hibernate.validator.internal.engine.constraintvalidation

pack-priv Class ComposingConstraintTree<B extends java.lang.annotation.Annotation>

extends ConstraintTree<B extends Annotation>
Class Inheritance
Static Imports
org.hibernate.validator.constraints.CompositionType.ALL_FALSE, .CompositionType.AND, .CompositionType.OR

A constraint tree for composing constraints. Has children corresponding to the composed constraints.
Authors
Hardy Ferentschik, Federico Mancini, Dag Hovland, Kevin Pollet <[email protected]> (C) 2012 SERLI, Guillaume Smet, Marko Bekhta

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final List<ConstraintTree<?>>
private static final Log
Inherited from org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree:
descriptor

Constructor Summary

AccessConstructor and Description
public
ComposingConstraintTree(ConstraintValidatorManager constraintValidatorManager, ConstraintDescriptorImpl<B> descriptor, Type validatedValueType)

Method Summary

Modifier and TypeMethod and Description
private <U extends Annotation> ConstraintTree<U>
createConstraintTree(ConstraintValidatorManager constraintValidatorManager, ConstraintDescriptorImpl<U> composingDescriptor)

private boolean
mainConstraintNeedsEvaluation(ValidationContext<?> validationContext, Collection<ConstraintValidatorContextImpl> violatedConstraintValidatorContexts)

private boolean
private void
prepareFinalConstraintViolations(ValidationContext<?>
meta data about top level validation
validationContext
,
ValueContext<?, ?>
meta data for currently validated value
valueContext
,
Collection<ConstraintValidatorContextImpl>
used to accumulate constraint validator contexts that cause constraint violations
violatedConstraintValidatorContexts
,
Optional<ConstraintValidatorContextImpl>
an optional of constraint violations of top level constraint
localConstraintValidatorContext
)

Before the final constraint violations can be reported back we need to check whether we have a composing constraint whose result should be reported as single violation.

private boolean

Returns:

true if the current constraint should be reported as single violation, 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
reportAsSingleViolation
()

private ComposingConstraintTree.CompositionResult

Returns:

Returns an instance of CompositionResult relevant for boolean composition of constraints
validateComposingConstraints
(ValidationContext<?>
Meta data about top level validation
validationContext
,
ValueContext<?, ?>
Meta data for currently validated value
valueContext
,
Collection<ConstraintValidatorContextImpl>
Used to accumulate constraint validator contexts that cause constraint violations
violatedConstraintValidatorContexts
)

Validates all composing constraints recursively.

protected void
Inherited from org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree:
getDescriptorgetInitializedConstraintValidatorgetValidatedValueTypeoftoStringvalidateConstraintsvalidateSingleConstraint

Field Detail

childrenback to summary
private final List<ConstraintTree<?>> children
Annotations
@Immutable
LOGback to summary
private static final Log LOG

Hides org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.LOG.

Constructor Detail

ComposingConstraintTreeback to summary
public ComposingConstraintTree(ConstraintValidatorManager constraintValidatorManager, ConstraintDescriptorImpl<B> descriptor, Type validatedValueType)

Method Detail

createConstraintTreeback to summary
private <U extends Annotation> ConstraintTree<U> createConstraintTree(ConstraintValidatorManager constraintValidatorManager, ConstraintDescriptorImpl<U> composingDescriptor)
mainConstraintNeedsEvaluationback to summary
private boolean mainConstraintNeedsEvaluation(ValidationContext<?> validationContext, Collection<ConstraintValidatorContextImpl> violatedConstraintValidatorContexts)
passesCompositionTypeRequirementback to summary
private boolean passesCompositionTypeRequirement(Collection<?> constraintViolations, ComposingConstraintTree.CompositionResult compositionResult)
prepareFinalConstraintViolationsback to summary
private void prepareFinalConstraintViolations(ValidationContext<?> validationContext, ValueContext<?, ?> valueContext, Collection<ConstraintValidatorContextImpl> violatedConstraintValidatorContexts, Optional<ConstraintValidatorContextImpl> localConstraintValidatorContext)

Before the final constraint violations can be reported back we need to check whether we have a composing constraint whose result should be reported as single violation.

Parameters
validationContext:ValidationContext<?>

meta data about top level validation

valueContext:ValueContext<?, ?>

meta data for currently validated value

violatedConstraintValidatorContexts:Collection<ConstraintValidatorContextImpl>

used to accumulate constraint validator contexts that cause constraint violations

localConstraintValidatorContext:Optional<ConstraintValidatorContextImpl>

an optional of constraint violations of top level constraint

reportAsSingleViolationback to summary
private boolean reportAsSingleViolation()
Returns:boolean

true if the current constraint should be reported as single violation, 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

validateComposingConstraintsback to summary
private ComposingConstraintTree.CompositionResult validateComposingConstraints(ValidationContext<?> validationContext, ValueContext<?, ?> valueContext, Collection<ConstraintValidatorContextImpl> violatedConstraintValidatorContexts)

Validates all composing constraints recursively.

Parameters
validationContext:ValidationContext<?>

Meta data about top level validation

valueContext:ValueContext<?, ?>

Meta data for currently validated value

violatedConstraintValidatorContexts:Collection<ConstraintValidatorContextImpl>

Used to accumulate constraint validator contexts that cause constraint violations

Returns:ComposingConstraintTree.CompositionResult

Returns an instance of CompositionResult relevant for boolean composition of constraints

validateConstraintsback to summary
protected void validateConstraints(ValidationContext<?> validationContext, ValueContext<?, ?> valueContext, Collection<ConstraintValidatorContextImpl> violatedConstraintValidatorContexts)

Implements abstract org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateConstraints.

Annotations
@Override
org.hibernate.validator.internal.engine.constraintvalidation back to summary

private final Class ComposingConstraintTree.CompositionResult

extends Object
Class Inheritance
  • java.lang.Object
  • org.hibernate.validator.internal.engine.constraintvalidation.ComposingConstraintTree.CompositionResult

Field Summary

Modifier and TypeField and Description
private boolean
private boolean

Constructor Summary

AccessConstructor and Description
pack-priv
CompositionResult(boolean allTrue, boolean atLeastOneTrue)

Method Summary

Modifier and TypeMethod and Description
public boolean
public boolean
public void
setAllTrue(boolean allTrue)

public void
setAtLeastOneTrue(boolean atLeastOneTrue)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allTrueback to summary
private boolean allTrue
atLeastOneTrueback to summary
private boolean atLeastOneTrue

Constructor Detail

CompositionResultback to summary
pack-priv CompositionResult(boolean allTrue, boolean atLeastOneTrue)

Method Detail

isAllTrueback to summary
public boolean isAllTrue()
isAtLeastOneTrueback to summary
public boolean isAtLeastOneTrue()
setAllTrueback to summary
public void setAllTrue(boolean allTrue)
setAtLeastOneTrueback to summary
public void setAtLeastOneTrue(boolean atLeastOneTrue)