GetterConstraintLocation( Class<?> declaringClass, Method method ) { this.method = method; this.accessibleMethod = getAccessible( method ); this.propertyName = ReflectionHelper.getPropertyName( method ); this.typeForValidatorResolution = ReflectionHelper.boxedType( ReflectionHelper.typeOf( method ) ); this.declaringClass = declaringClass; }
public MethodElement(Method method) { super( method.getName(), method.getParameterTypes() ); this.method = method; isGetterMethod = ReflectionHelper.isGetterMethod( method ); }
public ArrayElement(Type arrayType) { Class<?> arrayClass = ReflectionHelper.getClassFromType( arrayType ); if ( arrayClass.getComponentType().isPrimitive() ) { this.containerClass = arrayClass; } else { this.containerClass = Object[].class; } }
GetterCascadable(Method method, CascadingMetaData cascadingMetaData) { this.method = method; this.propertyName = ReflectionHelper.getPropertyName( method ); this.cascadableType = ReflectionHelper.typeOf( method ); this.cascadingMetaData = cascadingMetaData; }
private ConstraintLocation(Class<?> declaringClass, Member member, Type typeOfAnnotatedElement) { this.declaringClass = declaringClass; this.member = member; this.propertyName = member == null ? null : ReflectionHelper.getPropertyName( member ); if ( typeOfAnnotatedElement instanceof Class && ( (Class<?>) typeOfAnnotatedElement ).isPrimitive() ) { this.typeForValidatorResolution = ReflectionHelper.boxedType( (Class<?>) typeOfAnnotatedElement ); } else { this.typeForValidatorResolution = typeOfAnnotatedElement; } }
/** * Indicates whether the given type represents a collection of elements or not (i.e. whether it is an * {@code Iterable}, {@code Map} or array type). */ public static boolean isCollection(Type type) { return isIterable( type ) || isMap( type ) || TypeHelper.isArray( type ); }
/** * Indicates if the type is considered indexable (ie is a {@code List}, an array or a {@code Map}). * <p> * Note that it does not include {@code Set}s as they are not indexable. * * @param type the type to inspect. * * @return Returns true if the type is indexable. */ public static boolean isIndexable(Type type) { return isList( type ) || isMap( type ) || TypeHelper.isArray( type ); }
propertyPathNode = (NodeImpl) propertyPathIter.next(); clazz = ReflectionHelper.getClassFromType( ReflectionHelper.getCollectionElementType( propertyMetaData.getType() ) ); propertyMetaData = getBeanPropertyMetaData( clazz, propertyPathNode ); clazz = ReflectionHelper.getClassFromType( propertyMetaData.getType() );
value = ReflectionHelper.getIndexedValue( value, propertyPathNode.getIndex() ); value = ReflectionHelper.getMappedValue( value, propertyPathNode.getKey() );
if ( ReflectionHelper.isIterable( type ) || ReflectionHelper.isMap( type ) ) { Iterator<?> valueIter = Collections.singletonList( value ).iterator(); validateCascadedConstraint( boolean isIndexable = ReflectionHelper.isIndexable( type );
private String getPropertyName(ConstrainedElement constrainedElement) { if ( constrainedElement.getKind() == ConstrainedElementKind.FIELD ) { return ReflectionHelper.getPropertyName( ( (ConstrainedField) constrainedElement ).getField() ); } else if ( constrainedElement.getKind() == ConstrainedElementKind.METHOD ) { return ReflectionHelper.getPropertyName( ( (ConstrainedExecutable) constrainedElement ).getExecutable() ); } return null; }
/** * @param type the type to check. * * @return Returns <code>true</code> if <code>type</code> is a iterable type, <code>false</code> otherwise. */ public static boolean isIterable(Type type) { if ( type instanceof Class && Iterable.class.isAssignableFrom( (Class<?>) type ) ) { return true; } if ( type instanceof ParameterizedType ) { return isIterable( ( (ParameterizedType) type ).getRawType() ); } if ( type instanceof WildcardType ) { Type[] upperBounds = ( (WildcardType) type ).getUpperBounds(); return upperBounds.length != 0 && isIterable( upperBounds[0] ); } return false; }
private static Optional<Class<?>> getExtractedType(AnnotatedParameterizedType valueExtractorDefinition) { AnnotatedType containerType = valueExtractorDefinition.getAnnotatedActualTypeArguments()[0]; if ( containerType.isAnnotationPresent( ExtractedValue.class ) ) { Class<?> extractedType = containerType.getAnnotation( ExtractedValue.class ).type(); if ( !void.class.equals( extractedType ) ) { return Optional.of( ReflectionHelper.boxedType( extractedType ) ); } } return Optional.empty(); }
/** * @param type the type to check. * * @return Returns {@code true} if {@code type} is implementing {@code List}, {@code false} otherwise. */ public static boolean isList(Type type) { if ( type instanceof Class && List.class.isAssignableFrom( (Class<?>) type ) ) { return true; } if ( type instanceof ParameterizedType ) { return isList( ( (ParameterizedType) type ).getRawType() ); } if ( type instanceof WildcardType ) { Type[] upperBounds = ( (WildcardType) type ).getUpperBounds(); return upperBounds.length != 0 && isList( upperBounds[0] ); } return false; }
/** * Indicates whether the given type represents a collection of elements or not (i.e. whether it is an * {@code Iterable}, {@code Map} or array type). */ public static boolean isCollection(Type type) { return isIterable( type ) || isMap( type ) || TypeHelper.isArray( type ); }
public Builder(Class<?> beanClass, ConstrainedExecutable constrainedMethod, ConstraintHelper constraintHelper, TypeResolutionHelper typeResolutionHelper, ValueExtractorManager valueExtractorManager) { super( beanClass, constraintHelper, typeResolutionHelper, valueExtractorManager ); this.propertyName = ReflectionHelper.getPropertyName( constrainedMethod.getExecutable() ); this.propertyType = ReflectionHelper.typeOf( constrainedMethod.getExecutable() ); add( constrainedMethod ); }
@Override public Object getValue(Object parent) { return ReflectionHelper.getValue( accessibleField, parent ); }