@Override public String toString() { final StringBuilder sb = new StringBuilder(); sb.append( "MetaConstraint" ); sb.append( "{constraintType=" ).append( constraintDescriptor.getAnnotation().annotationType().getName() ); sb.append( ", location=" ).append( location ); sb.append( "}" ); return sb.toString(); } }
@Override public String toString() { final StringBuilder sb = new StringBuilder(); sb.append( "MetaConstraint" ); sb.append( "{constraintType=" ).append( StringHelper.toShortString( constraintTree.getDescriptor().getAnnotation().annotationType() ) ); sb.append( ", location=" ).append( location ); sb.append( ", valueExtractionPath=" ).append( valueExtractionPath ); sb.append( "}" ); return sb.toString(); }
@Override public String toString() { //display short annotation type names StringBuilder sb = new StringBuilder(); for ( MetaConstraint<?> oneConstraint : getConstraints() ) { sb.append( oneConstraint.getDescriptor().getAnnotation().annotationType().getSimpleName() ); sb.append( ", " ); } String constraintsAsString = sb.length() > 0 ? sb.substring( 0, sb.length() - 2 ) : sb.toString(); return "ParameterMetaData [executable=" + executable + ", index=" + index + "], constraints=[" + constraintsAsString + "]"; }
@Override public String toString() { //display short annotation type names StringBuilder sb = new StringBuilder(); for ( MetaConstraint<?> oneConstraint : getConstraints() ) { sb.append( oneConstraint.getDescriptor().getAnnotation().annotationType().getSimpleName() ); sb.append( ", " ); } String constraintsAsString = sb.length() > 0 ? sb.substring( 0, sb.length() - 2 ) : sb.toString(); return "ParameterMetaData [location=" + getLocation() + "], name=" + name + "], constraints=[" + constraintsAsString + "], isCascading=" + isCascading() + "]"; }
/** * @param validatedValueType the type of the value to be validated. Cannot be {@code null}. * @param descriptor the constraint descriptor for which to get an initialized constraint validator. Cannot be {@code null} * @param constraintFactory constraint factory used to instantiate the constraint validator. Cannot be {@code null}. * @param <V> the type of the value to be validated * @param <A> the annotation type * * @return an initialized constraint validator for the given type and annotation of the value to be validated. * {@code null} is returned if no matching constraint validator could be found. */ public <V, A extends Annotation> ConstraintValidator<A, V> getInitializedValidator(Type validatedValueType, ConstraintDescriptorImpl<A> descriptor, ConstraintValidatorFactory constraintFactory) { Contracts.assertNotNull( validatedValueType ); Contracts.assertNotNull( descriptor ); Contracts.assertNotNull( constraintFactory ); CacheKey key = new CacheKey( descriptor.getAnnotation(), validatedValueType, constraintFactory ); @SuppressWarnings("unchecked") ConstraintValidator<A, V> constraintValidator = (ConstraintValidator<A, V>) constraintValidatorCache.get( key ); if ( constraintValidator == null ) { constraintValidator = createAndInitializeValidator( constraintFactory, validatedValueType, descriptor ); constraintValidator = cacheValidator( key, constraintValidator ); } else { LOG.tracef( "Constraint validator %s found in cache.", constraintValidator ); } return DUMMY_CONSTRAINT_VALIDATOR == constraintValidator ? null : constraintValidator; }
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() ); }