public ValidationEnabledAnnotatedType(AnnotatedType<T> type, Set<AnnotatedCallable<? super T>> constrainedCallables) { this.wrappedType = type; this.wrappedMethods = CollectionHelper.newHashSet(); this.wrappedConstructors = CollectionHelper.newHashSet(); buildWrappedCallable( constrainedCallables ); }
public ValidatorFactoryBean(BeanManager beanManager, ValidationProviderHelper validationProviderHelper) { this.beanManager = beanManager; this.destructibleResources = newHashSet( 5 ); this.validationProviderHelper = validationProviderHelper; this.types = Collections.unmodifiableSet( CollectionHelper.<Type>newHashSet( ClassHierarchyHelper.getHierarchy( validationProviderHelper.getValidatorFactoryBeanClass() ) ) ); }
/** * Returns the qualifiers to be used for registering a validator or validator factory. */ @SuppressWarnings("serial") private static Set<Annotation> determineRequiredQualifiers(boolean isDefaultProvider, boolean isHibernateValidator) { HashSet<Annotation> qualifiers = newHashSet( 3 ); if ( isDefaultProvider ) { qualifiers.add( new AnnotationLiteral<Default>() { } ); } if ( isHibernateValidator ) { qualifiers.add( new AnnotationLiteral<HibernateValidator>() { } ); } qualifiers.add( new AnnotationLiteral<Any>() { } ); return qualifiers; }
public ValidatorBean(BeanManager beanManager, Bean<?> validatorFactoryBean, ValidationProviderHelper validationProviderHelper) { this.beanManager = beanManager; this.validatorFactoryBean = validatorFactoryBean; this.validationProviderHelper = validationProviderHelper; this.types = Collections.unmodifiableSet( CollectionHelper.<Type>newHashSet( ClassHierarchyHelper.getHierarchy( validationProviderHelper.getValidatorBeanClass() ) ) ); }
public DefaultConstraintMapping() { this.annotationProcessingOptions = new AnnotationProcessingOptionsImpl(); this.configuredTypes = newHashSet(); this.typeContexts = newHashSet(); this.definedConstraints = newHashSet(); this.constraintContexts = newHashSet(); }
private List<Object> findDuplicates(Collection<?> collection) { Set<Object> uniqueElements = CollectionHelper.newHashSet( collection.size() ); return collection.stream().filter( o -> !uniqueElements.add( o ) ) .collect( toList() ); } }
private static void putPrimitiveSubtypes(Map<Class<?>, Set<Class<?>>> subtypesByPrimitive, Class<?> primitiveType, Class<?>... directSubtypes) { Set<Class<?>> subtypes = newHashSet(); for ( Class<?> directSubtype : directSubtypes ) { subtypes.add( directSubtype ); subtypes.addAll( subtypesByPrimitive.get( directSubtype ) ); } subtypesByPrimitive.put( primitiveType, Collections.unmodifiableSet( subtypes ) ); }
@Override public Enumeration<String> getKeys() { Set<String> keySet = newHashSet(); keySet.addAll( properties.stringPropertyNames() ); if ( parent != null ) { keySet.addAll( Collections.list( parent.getKeys() ) ); } return Collections.enumeration( keySet ); } }
@Override public Enumeration<String> getKeys() { final Set<String> keySet = CollectionHelper.newHashSet(); keySet.addAll(this.properties.stringPropertyNames()); if (this.parent != null) { keySet.addAll(Collections.list(this.parent.getKeys())); } return Collections.enumeration(keySet); } }
protected Set<ConstraintDescriptorImpl<?>> asDescriptors(Set<MetaConstraint<?>> constraints) { Set<ConstraintDescriptorImpl<?>> theValue = newHashSet(); for ( MetaConstraint<?> oneConstraint : constraints ) { theValue.add( oneConstraint.getDescriptor() ); } return theValue; } }
protected Set<MetaConstraint<?>> getConstraints(ConstraintHelper constraintHelper, TypeResolutionHelper typeResolutionHelper, ValueExtractorManager valueExtractorManager) { if ( constraints == null ) { return Collections.emptySet(); } Set<MetaConstraint<?>> metaConstraints = newHashSet(); for ( ConfiguredConstraint<?> configuredConstraint : constraints ) { metaConstraints.add( asMetaConstraint( configuredConstraint, constraintHelper, typeResolutionHelper, valueExtractorManager ) ); } return metaConstraints; }
protected Set<ConstraintDescriptorImpl<?>> asDescriptors(Set<MetaConstraint<?>> constraints) { Set<ConstraintDescriptorImpl<?>> theValue = newHashSet(); for ( MetaConstraint<?> oneConstraint : constraints ) { theValue.add( oneConstraint.getDescriptor() ); } return theValue; }
public Set<ConstraintDefinitionContribution<?>> getConstraintDefinitionContributions() { Set<ConstraintDefinitionContribution<?>> contributions = newHashSet(); for ( ConstraintDefinitionContextImpl<?> constraintContext : constraintContexts ) { contributions.add( constraintContext.build() ); } return contributions; } }
@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 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 ); }
public ValidatableParametersMetaData getValidatableParametersMetaData() { Set<ParameterMetaData> cascadedParameters = newHashSet(); for ( ParameterMetaData parameterMetaData : parameterMetaDataList ) { if ( parameterMetaData.isCascading() ) { cascadedParameters.add( parameterMetaData ); } } return new ValidatableParametersMetaData( cascadedParameters ); }
private static void registerCustomConstraintValidators(Set<DefaultConstraintMapping> constraintMappings, ConstraintHelper constraintHelper) { Set<Class<?>> definedConstraints = newHashSet(); for ( DefaultConstraintMapping constraintMapping : constraintMappings ) { for ( ConstraintDefinitionContribution<?> contribution : constraintMapping.getConstraintDefinitionContributions() ) { processConstraintDefinitionContribution( contribution, constraintHelper, definedConstraints ); } } }
private Set<ConstrainedElement> getFieldMetaData(Class<?> beanClass) { Set<ConstrainedElement> propertyMetaData = newHashSet(); for ( Field field : run( GetDeclaredFields.action( beanClass ) ) ) { // HV-172 if ( Modifier.isStatic( field.getModifiers() ) || annotationProcessingOptions.areMemberConstraintsIgnoredFor( field ) || field.isSynthetic() ) { continue; } propertyMetaData.add( findPropertyMetaData( field ) ); } return propertyMetaData; }
private Set<ConstrainedExecutable> getMetaData(Executable[] executableElements) { Set<ConstrainedExecutable> executableMetaData = newHashSet(); for ( Executable executable : executableElements ) { // HV-172; ignoring synthetic methods (inserted by the compiler), as they can't have any constraints // anyway and possibly hide the actual method with the same signature in the built meta model if ( Modifier.isStatic( executable.getModifiers() ) || executable.isSynthetic() ) { continue; } executableMetaData.add( findExecutableMetaData( executable ) ); } return executableMetaData; }
public Set<ConstraintViolation<T>> createConstraintViolations(ValueContext<?, ?> localContext, ConstraintValidatorContextImpl constraintValidatorContext) { Set<ConstraintViolation<T>> constraintViolations = newHashSet(); for ( ConstraintViolationCreationContext constraintViolationCreationContext : constraintValidatorContext.getConstraintViolationCreationContexts() ) { ConstraintViolation<T> violation = createConstraintViolation( localContext, constraintViolationCreationContext, constraintValidatorContext.getConstraintDescriptor() ); constraintViolations.add( violation ); } return constraintViolations; }