Class FieldFinder.MultipleFieldsFinder
- All Implemented Interfaces:
IAccessibleSetter<FieldFinder.MultipleFieldsFinder>, IAnnotationFinder<FieldFinder.MultipleFieldsFinder>
- Enclosing class:
FieldFinder
ReflectionFinder to retrieve all fields in a class of a given type.-
Nested Class Summary
Nested classes/interfaces inherited from class ReflectionFinder
ReflectionFinder.ReflectionFinderWithParameters<T,U> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Class<? extends Annotation>[]protected booleanprotected booleanFields inherited from class ReflectionFinder
modifiers -
Method Summary
Modifier and TypeMethodDescriptionatLeast(int val) Configures the lower bound number of fields that have to be found.atMost(int val) Configures the upper bound number of fields that have to be found.Used to configure the field finder to include the source class's superclasses when searching for the target field.exactCount(int val) Configures the exact number of fields that have to be found.get()Retrieves the target reflection object(s) using the current configuration.Retrieves the target reflection object(s) using the current configuration.Sets the returned reflection object(s) as accessible.withAnnotations(Class<? extends Annotation>... annotations) Adds a requirement that the target constructor should contain at least a set of given annotations.Methods inherited from class ReflectionFinder
addModifiers, withModifiers
-
Field Details
-
setAccessible
protected boolean setAccessible -
checkSuperClasses
protected boolean checkSuperClasses -
annotations
-
-
Method Details
-
get
Retrieves the target reflection object(s) using the current configuration.This may throw an exception if the lookup hasn't been configured yet.
- Specified by:
getin classReflectionFinder<List<Field>, FieldFinder.MultipleFieldsFinder>- Returns:
- The fields that were requested, if any were found.
- Throws:
NullPointerException- If no fields could be found.
-
getNullable
Retrieves the target reflection object(s) using the current configuration.This may throw an exception if the lookup hasn't been configured yet.
- Specified by:
getNullablein classReflectionFinder<List<Field>, FieldFinder.MultipleFieldsFinder>- Returns:
- The fields that were requested, if any were found, otherwise an empty list.
-
atLeast
Configures the lower bound number of fields that have to be found.For example, when this is set to 2 and only 1 field could be found with the current configuration,
getNullable()will either return null (when null values are allowed) or throw aIllegalStateException(default).- Parameters:
val- The minimum number of fields that have to be found for this finder to be able to complete successfully.- Returns:
- The instance of the current finder.
-
atMost
Configures the upper bound number of fields that have to be found.For example, when this is set to 2 and 3 fields could be found with the current configuration,
getNullable()will either return null (when null values are allowed) or throw aIllegalStateException(default).- Parameters:
val- The maximum number of fields that can be found for this finder to be able to complete successfully.- Returns:
- The instance of the current finder.
-
exactCount
Configures the exact number of fields that have to be found.For example, when this is set to 2 and 1 or 3 fields could be found with the current configuration,
getNullable()will either return null (when null values are allowed) or throw aIllegalStateException(default).- Parameters:
val- The exact number of fields that must be found for this finder to be able to complete successfully.- Returns:
- The instance of the current finder.
-
setAccessible
Description copied from interface:IAccessibleSetterSets the returned reflection object(s) as accessible.- Specified by:
setAccessiblein interfaceIAccessibleSetter<T>- Returns:
- The current object.
-
withAnnotations
@SafeVarargs public final FieldFinder.MultipleFieldsFinder withAnnotations(Class<? extends Annotation>... annotations) Description copied from interface:IAnnotationFinderAdds a requirement that the target constructor should contain at least a set of given annotations.- Specified by:
withAnnotationsin interfaceIAnnotationFinder<T>- Parameters:
annotations- The annotations the constructor should have.- Returns:
- The current object.
-
checkSuperClasses
Used to configure the field finder to include the source class's superclasses when searching for the target field.- Returns:
- The current field finder instance.
-