public final Set<InputStream> getMappings() { return CollectionHelper.toImmutableSet( mappings ); }
ValueExtractorResolver(Set<ValueExtractorDescriptor> valueExtractors) { this.registeredValueExtractors = CollectionHelper.toImmutableSet( valueExtractors ); }
public PropertyDescriptorImpl(Type returnType, String propertyName, Set<ConstraintDescriptorImpl<?>> constraints, Set<ContainerElementTypeDescriptor> constrainedContainerElementTypes, boolean cascaded, boolean defaultGroupSequenceRedefined, List<Class<?>> defaultGroupSequence, Set<GroupConversionDescriptor> groupConversions) { super( returnType, constraints, defaultGroupSequenceRedefined, defaultGroupSequence ); this.propertyName = propertyName; this.constrainedContainerElementTypes = CollectionHelper.toImmutableSet( constrainedContainerElementTypes ); this.cascaded = cascaded; this.groupConversions = CollectionHelper.toImmutableSet( groupConversions ); }
public GroupWithInheritance(Set<Group> groups) { this.groups = CollectionHelper.toImmutableSet( groups ); }
public ContainerElementTypeDescriptorImpl(Type type, Class<?> containerClass, Integer typeArgumentIndex, Set<ConstraintDescriptorImpl<?>> constraints, Set<ContainerElementTypeDescriptor> constrainedContainerElementTypes, boolean cascaded, boolean defaultGroupSequenceRedefined, List<Class<?>> defaultGroupSequence, Set<GroupConversionDescriptor> groupConversions) { super( type, constraints, defaultGroupSequenceRedefined, defaultGroupSequence ); this.containerClass = containerClass; this.typeArgumentIndex = typeArgumentIndex; this.constrainedContainerElementTypes = CollectionHelper.toImmutableSet( constrainedContainerElementTypes ); this.cascaded = cascaded; this.groupConversions = CollectionHelper.toImmutableSet( groupConversions ); }
public ParameterDescriptorImpl(Type type, int index, String name, Set<ConstraintDescriptorImpl<?>> constraints, Set<ContainerElementTypeDescriptor> constrainedContainerElementTypes, boolean isCascaded, boolean defaultGroupSequenceRedefined, List<Class<?>> defaultGroupSequence, Set<GroupConversionDescriptor> groupConversions) { super( type, constraints, defaultGroupSequenceRedefined, defaultGroupSequence ); this.index = index; this.name = name; this.constrainedContainerElementTypes = CollectionHelper.toImmutableSet( constrainedContainerElementTypes ); this.cascaded = isCascaded; this.groupConversions = CollectionHelper.toImmutableSet( groupConversions ); }
public ReturnValueDescriptorImpl(Type returnType, Set<ConstraintDescriptorImpl<?>> returnValueConstraints, Set<ContainerElementTypeDescriptor> constrainedContainerElementTypes, boolean cascaded, boolean defaultGroupSequenceRedefined, List<Class<?>> defaultGroupSequence, Set<GroupConversionDescriptor> groupConversions) { super( returnType, returnValueConstraints, defaultGroupSequenceRedefined, defaultGroupSequence ); this.constrainedContainerElementTypes = CollectionHelper.toImmutableSet( constrainedContainerElementTypes ); this.cascaded = cascaded; this.groupConversions = CollectionHelper.toImmutableSet( groupConversions ); }
public AbstractConstrainedElement(ConfigurationSource source, ConstrainedElementKind kind, Set<MetaConstraint<?>> constraints, Set<MetaConstraint<?>> typeArgumentConstraints, CascadingMetaDataBuilder cascadingMetaDataBuilder) { this.kind = kind; this.source = source; this.constraints = constraints != null ? CollectionHelper.toImmutableSet( constraints ) : Collections.<MetaConstraint<?>>emptySet(); this.typeArgumentConstraints = typeArgumentConstraints != null ? CollectionHelper.toImmutableSet( typeArgumentConstraints ) : Collections.<MetaConstraint<?>>emptySet(); this.cascadingMetaDataBuilder = cascadingMetaDataBuilder; }
public AbstractConstraintMetaData(String name, Type type, Set<MetaConstraint<?>> directConstraints, Set<MetaConstraint<?>> containerElementsConstraints, boolean isCascading, boolean isConstrained) { this.name = name; this.type = type; this.directConstraints = CollectionHelper.toImmutableSet( directConstraints ); this.containerElementsConstraints = CollectionHelper.toImmutableSet( containerElementsConstraints ); this.allConstraints = Stream.concat( directConstraints.stream(), containerElementsConstraints.stream() ) .collect( Collectors.collectingAndThen( Collectors.toSet(), CollectionHelper::toImmutableSet ) ); this.isCascading = isCascading; this.isConstrained = isConstrained; }
private PropertyMetaData(String propertyName, Type type, Set<MetaConstraint<?>> constraints, Set<MetaConstraint<?>> containerElementsConstraints, Set<Cascadable> cascadables, boolean cascadingProperty) { super( propertyName, type, constraints, containerElementsConstraints, !cascadables.isEmpty(), !cascadables.isEmpty() || !constraints.isEmpty() || !containerElementsConstraints.isEmpty() ); this.cascadables = CollectionHelper.toImmutableSet( cascadables ); }
private Set<ExecutableType> prepareValidatedExecutableTypes(EnumSet<ExecutableType> validatedExecutableTypes) { if ( validatedExecutableTypes == null ) { return DEFAULT_VALIDATED_EXECUTABLE_TYPES; } if ( validatedExecutableTypes.contains( ExecutableType.ALL ) ) { return ALL_VALIDATED_EXECUTABLE_TYPES; } if ( validatedExecutableTypes.contains( ExecutableType.NONE ) ) { if ( validatedExecutableTypes.size() == 1 ) { return Collections.emptySet(); } else { EnumSet<ExecutableType> preparedValidatedExecutableTypes = EnumSet.copyOf( validatedExecutableTypes ); preparedValidatedExecutableTypes.remove( ExecutableType.NONE ); return CollectionHelper.toImmutableSet( preparedValidatedExecutableTypes ); } } return CollectionHelper.toImmutableSet( validatedExecutableTypes ); }
@Override public Set<ConstraintDescriptor<?>> getConstraintDescriptors() { Set<ConstraintDescriptor<?>> matchingDescriptors = new HashSet<ConstraintDescriptor<?>>(); findMatchingDescriptors( matchingDescriptors ); return CollectionHelper.toImmutableSet( matchingDescriptors ); }
@SuppressWarnings("unchecked") private static Set<Class<? extends Payload>> buildPayloadSet(ConstraintAnnotationDescriptor<?> annotationDescriptor) { Set<Class<? extends Payload>> payloadSet = newHashSet(); Class<? extends Payload>[] payloadFromAnnotation = annotationDescriptor.getPayload(); if ( payloadFromAnnotation != null ) { payloadSet.addAll( Arrays.asList( payloadFromAnnotation ) ); } return CollectionHelper.toImmutableSet( payloadSet ); }
private static Set<Class<?>> buildGroupSet(ConstraintAnnotationDescriptor<?> annotationDescriptor, Class<?> implicitGroup) { Set<Class<?>> groupSet = newHashSet(); final Class<?>[] groupsFromAnnotation = annotationDescriptor.getGroups(); if ( groupsFromAnnotation.length == 0 ) { groupSet.add( Default.class ); } else { groupSet.addAll( Arrays.asList( groupsFromAnnotation ) ); } // if the constraint is part of the Default group it is automatically part of the implicit group as well if ( implicitGroup != null && groupSet.contains( Default.class ) ) { groupSet.add( implicitGroup ); } return CollectionHelper.toImmutableSet( groupSet ); }
/** * Returns a set with {@link GroupConversionDescriptor}s representing the * underlying group conversions. * * @return A set with group conversion descriptors. May be empty, but never * {@code null}. */ public Set<GroupConversionDescriptor> asDescriptors() { Set<GroupConversionDescriptor> descriptors = newHashSet( groupConversions.size() ); for ( Entry<Class<?>, Class<?>> conversion : groupConversions.entrySet() ) { descriptors.add( new GroupConversionDescriptorImpl( conversion.getKey(), conversion.getValue() ) ); } return CollectionHelper.toImmutableSet( descriptors ); }
public ElementDescriptorImpl(Type type, Set<ConstraintDescriptorImpl<?>> constraintDescriptors, boolean defaultGroupSequenceRedefined, List<Class<?>> defaultGroupSequence) { this.type = (Class<?>) TypeHelper.getErasedType( type ); this.constraintDescriptors = CollectionHelper.toImmutableSet( constraintDescriptors ); this.defaultGroupSequenceRedefined = defaultGroupSequenceRedefined; this.defaultGroupSequence = CollectionHelper.toImmutableList( defaultGroupSequence ); }
/** * Used to determine the value extractor candidates valid for a declared type and type variable. * <p> * The effective value extractor will be narrowed from these candidates using the runtime type. * <p> * Used to optimize the choice of the value extractor in the case of cascading validation. */ public Set<ValueExtractorDescriptor> getValueExtractorCandidatesForCascadedValidation(Type declaredType, TypeVariable<?> typeParameter) { Set<ValueExtractorDescriptor> valueExtractorDescriptors = new HashSet<>(); valueExtractorDescriptors.addAll( getRuntimeAndContainerElementCompliantValueExtractorsFromPossibleCandidates( declaredType, typeParameter, TypeHelper.getErasedReferenceType( declaredType ), registeredValueExtractors ) ); valueExtractorDescriptors.addAll( getPotentiallyRuntimeTypeCompliantAndContainerElementCompliantValueExtractors( declaredType, typeParameter ) ); return CollectionHelper.toImmutableSet( valueExtractorDescriptors ); }
private Set<MetaConstraint<?>> getDirectConstraints() { Set<MetaConstraint<?>> constraints = newHashSet(); Set<Class<?>> classAndInterfaces = newHashSet(); classAndInterfaces.add( beanClass ); classAndInterfaces.addAll( ClassHierarchyHelper.getDirectlyImplementedInterfaces( beanClass ) ); for ( Class<?> clazz : classAndInterfaces ) { for ( MetaConstraint<?> metaConstraint : allMetaConstraints ) { if ( metaConstraint.getLocation().getDeclaringClass().equals( clazz ) ) { constraints.add( metaConstraint ); } } } return CollectionHelper.toImmutableSet( constraints ); }
private static Set<MethodConfigurationRule> buildConfiguredRuleSet(boolean allowOverridingMethodAlterParameterConstraint, boolean allowMultipleCascadedValidationOnReturnValues, boolean allowParallelMethodsDefineParameterConstraints) { HashSet<MethodConfigurationRule> result = newHashSet( 5 ); if ( !allowOverridingMethodAlterParameterConstraint ) { result.add( new OverridingMethodMustNotAlterParameterConstraints() ); } if ( !allowParallelMethodsDefineParameterConstraints ) { result.add( new ParallelMethodsMustNotDefineParameterConstraints() ); } result.add( new VoidMethodsMustNotBeReturnValueConstrained() ); if ( !allowMultipleCascadedValidationOnReturnValues ) { result.add( new ReturnValueMayOnlyBeMarkedOnceAsCascadedPerHierarchyLine() ); } result.add( new ParallelMethodsMustNotDefineGroupConversionForCascadedReturnValue() ); return CollectionHelper.toImmutableSet( result ); }
@Override public ExecutableMetaData build() { assertCorrectnessOfConfiguration(); return new ExecutableMetaData( kind == ConstrainedElement.ConstrainedElementKind.CONSTRUCTOR ? executable.getDeclaringClass().getSimpleName() : executable.getName(), ReflectionHelper.typeOf( executable ), executable.getParameterTypes(), kind == ConstrainedElement.ConstrainedElementKind.CONSTRUCTOR ? ElementKind.CONSTRUCTOR : ElementKind.METHOD, kind == ConstrainedElement.ConstrainedElementKind.CONSTRUCTOR ? Collections.singleton( ExecutableHelper.getSignature( executable ) ) : CollectionHelper.toImmutableSet( signatures ), adaptOriginsAndImplicitGroups( getDirectConstraints() ), adaptOriginsAndImplicitGroups( getContainerElementConstraints() ), findParameterMetaData(), adaptOriginsAndImplicitGroups( crossParameterConstraints ), cascadingMetaDataBuilder.build( valueExtractorManager, executable ), isConstrained, isGetterMethod ); }