public ComposingConstraintTree(ConstraintDescriptorImpl<B> descriptor, Type validatedValueType) { super( descriptor, validatedValueType ); this.children = descriptor.getComposingConstraintImpls().stream() .map( desc -> createConstraintTree( desc ) ) .collect( Collectors.collectingAndThen( Collectors.toList(), CollectionHelper::toImmutableList ) ); }
private ConstraintTree(ConstraintDescriptorImpl<A> descriptor, ConstraintTree<?> parent) { this.parent = parent; this.descriptor = descriptor; final Set<ConstraintDescriptorImpl<?>> composingConstraints = descriptor.getComposingConstraintImpls(); children = newArrayList( composingConstraints.size() ); for ( ConstraintDescriptorImpl<?> composingDescriptor : composingConstraints ) { ConstraintTree<?> treeNode = createConstraintTree( composingDescriptor ); children.add( treeNode ); } }
public static <U extends Annotation> ConstraintTree<U> of(ConstraintDescriptorImpl<U> composingDescriptor, Type validatedValueType) { if ( composingDescriptor.getComposingConstraintImpls().isEmpty() ) { return new SimpleConstraintTree<>( composingDescriptor, validatedValueType ); } else { return new ComposingConstraintTree<>( composingDescriptor, validatedValueType ); } }
private <U extends Annotation> ConstraintTree<U> createConstraintTree(ConstraintDescriptorImpl<U> composingDescriptor) { if ( composingDescriptor.getComposingConstraintImpls().isEmpty() ) { return new SimpleConstraintTree<>( composingDescriptor, getValidatedValueType() ); } else { return new ComposingConstraintTree<>( composingDescriptor, getValidatedValueType() ); } }
/** * Asserts that this constraint and all its composing constraints share the * same constraint type (generic or cross-parameter). */ private void validateComposingConstraintTypes() { for ( ConstraintDescriptorImpl<?> composingConstraint : getComposingConstraintImpls() ) { if ( composingConstraint.constraintType != constraintType ) { throw LOG.getComposedAndComposingConstraintsHaveDifferentTypesException( annotationDescriptor.getType(), composingConstraint.annotationDescriptor.getType(), constraintType, composingConstraint.constraintType ); } } }