@Override public ConstraintType getPartition(ConstraintDescriptorImpl<?> v) { return v.getConstraintType(); } };
private ValidationException getExceptionForNullValidator(Type validatedValueType, String path) { if ( descriptor.getConstraintType() == ConstraintDescriptorImpl.ConstraintType.CROSS_PARAMETER ) { return LOG.getValidatorForCrossParameterConstraintMustEitherValidateObjectOrObjectArrayException( descriptor.getAnnotationType() ); } else { String className = validatedValueType.toString(); if ( validatedValueType instanceof Class ) { Class<?> clazz = (Class<?>) validatedValueType; if ( clazz.isArray() ) { className = clazz.getComponentType().toString() + "[]"; } else { className = clazz.getName(); } } return LOG.getNoValidatorFoundForTypeException( descriptor.getAnnotationType(), className, path ); } }
private void throwExceptionForNullValidator(Type validatedValueType, String path) { if ( descriptor.getConstraintType() == ConstraintDescriptorImpl.ConstraintType.CROSS_PARAMETER ) { throw log.getValidatorForCrossParameterConstraintMustEitherValidateObjectOrObjectArrayException( descriptor.getAnnotationType() ); } else { String className = validatedValueType.toString(); if ( validatedValueType instanceof Class ) { Class<?> clazz = (Class<?>) validatedValueType; if ( clazz.isArray() ) { className = clazz.getComponentType().toString() + "[]"; } else { className = clazz.getName(); } } throw log.getNoValidatorFoundForTypeException( descriptor.getAnnotationType(), className, path ); } }
private Set<MetaConstraint<?>> convertToMetaConstraints(List<ConstraintDescriptorImpl<?>> constraintsDescriptors, Executable executable) { if ( constraintsDescriptors == null ) { return Collections.emptySet(); } Set<MetaConstraint<?>> constraints = newHashSet(); ConstraintLocation returnValueLocation = ConstraintLocation.forReturnValue( executable ); ConstraintLocation crossParameterLocation = ConstraintLocation.forCrossParameter( executable ); for ( ConstraintDescriptorImpl<?> constraintDescriptor : constraintsDescriptors ) { ConstraintLocation location = constraintDescriptor.getConstraintType() == ConstraintType.GENERIC ? returnValueLocation : crossParameterLocation; constraints.add( MetaConstraints.create( typeResolutionHelper, valueExtractorManager, constraintDescriptor, location ) ); } return constraints; }
private Set<MetaConstraint<?>> convertToMetaConstraints(List<ConstraintDescriptorImpl<?>> constraintsDescriptors, ExecutableElement executable) { if ( constraintsDescriptors == null ) { return Collections.emptySet(); } Set<MetaConstraint<?>> constraints = newHashSet(); ConstraintLocation returnValueLocation = ConstraintLocation.forReturnValue( executable ); ConstraintLocation crossParameterLocation = ConstraintLocation.forCrossParameter( executable ); for ( ConstraintDescriptorImpl<?> constraintDescriptor : constraintsDescriptors ) { constraints.add( createMetaConstraint( constraintDescriptor, constraintDescriptor.getConstraintType() == ConstraintType.GENERIC ? returnValueLocation : crossParameterLocation ) ); } return constraints; }
private <A extends Annotation> MetaConstraint<A> adaptOriginAndImplicitGroup(MetaConstraint<A> constraint) { ConstraintOrigin definedIn = definedIn( beanClass, constraint.getLocation().getDeclaringClass() ); if ( definedIn == ConstraintOrigin.DEFINED_LOCALLY ) { return constraint; } Class<?> constraintClass = constraint.getLocation().getDeclaringClass(); ConstraintDescriptorImpl<A> descriptor = new ConstraintDescriptorImpl<>( constraintHelper, constraint.getLocation().getMember(), constraint.getDescriptor().getAnnotationDescriptor(), constraint.getElementType(), constraintClass.isInterface() ? constraintClass : null, definedIn, constraint.getDescriptor().getConstraintType() ); return MetaConstraints.create( typeResolutionHelper, valueExtractorManager, descriptor, constraint.getLocation() ); }
private <A extends Annotation> MetaConstraint<A> adaptOriginAndImplicitGroup(MetaConstraint<A> constraint) { ConstraintOrigin definedIn = definedIn( beanClass, constraint.getLocation().getDeclaringClass() ); if ( definedIn == ConstraintOrigin.DEFINED_LOCALLY ) { return constraint; } Class<?> constraintClass = constraint.getLocation().getDeclaringClass(); ConstraintDescriptorImpl<A> descriptor = new ConstraintDescriptorImpl<A>( constraintHelper, constraint.getLocation().getMember(), constraint.getDescriptor().getAnnotation(), constraint.getElementType(), constraintClass.isInterface() ? constraintClass : null, definedIn, constraint.getDescriptor().getConstraintType() ); return new MetaConstraint<A>( descriptor, constraint.getLocation() ); }