Class FieldFinder.MultipleFieldsFinder

java.lang.Object
nl.pim16aap2.util.reflection.ReflectionFinder<List<Field>, FieldFinder.MultipleFieldsFinder>
nl.pim16aap2.util.reflection.FieldFinder.MultipleFieldsFinder
All Implemented Interfaces:
IAccessibleSetter<FieldFinder.MultipleFieldsFinder>, IAnnotationFinder<FieldFinder.MultipleFieldsFinder>
Enclosing class:
FieldFinder

public static final class FieldFinder.MultipleFieldsFinder extends ReflectionFinder<List<Field>, FieldFinder.MultipleFieldsFinder>
Represents an implementation of ReflectionFinder to retrieve all fields in a class of a given type.
  • Field Details

    • setAccessible

      protected boolean setAccessible
    • checkSuperClasses

      protected boolean checkSuperClasses
    • annotations

      protected Class<? extends Annotation>[] annotations
  • Method Details

    • get

      public List<Field> 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:
      get in class ReflectionFinder<List<Field>, FieldFinder.MultipleFieldsFinder>
      Returns:
      The fields that were requested, if any were found.
      Throws:
      NullPointerException - If no fields could be found.
    • getNullable

      public List<Field> 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:
      getNullable in class ReflectionFinder<List<Field>, FieldFinder.MultipleFieldsFinder>
      Returns:
      The fields that were requested, if any were found, otherwise an empty list.
    • atLeast

      public FieldFinder.MultipleFieldsFinder atLeast(int val)
      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 a IllegalStateException (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

      public FieldFinder.MultipleFieldsFinder atMost(int val)
      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 a IllegalStateException (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

      public FieldFinder.MultipleFieldsFinder exactCount(int val)
      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 a IllegalStateException (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

      public FieldFinder.MultipleFieldsFinder setAccessible()
      Description copied from interface: IAccessibleSetter
      Sets the returned reflection object(s) as accessible.

      See AccessibleObject.setAccessible(boolean).

      Specified by:
      setAccessible in interface IAccessibleSetter<T>
      Returns:
      The current object.
    • withAnnotations

      @SafeVarargs public final FieldFinder.MultipleFieldsFinder withAnnotations(Class<? extends Annotation>... annotations)
      Description copied from interface: IAnnotationFinder
      Adds a requirement that the target constructor should contain at least a set of given annotations.
      Specified by:
      withAnnotations in interface IAnnotationFinder<T>
      Parameters:
      annotations - The annotations the constructor should have.
      Returns:
      The current object.
    • checkSuperClasses

      public FieldFinder.MultipleFieldsFinder 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.