Class ReflectionFinder<T,U extends ReflectionFinder<T,U>>

java.lang.Object
nl.pim16aap2.util.reflection.ReflectionFinder<T,U>
Type Parameters:
T - The type of objects to retrieve using reflection (e.g. Field, Method, etc.)
U - The type of finder being used to find the reflection object.
Direct Known Subclasses:
ClassFinder, EnumValuesFinder, EnumValuesFinder.IndexedEnumValueFinder, EnumValuesFinder.NamedEnumValueFinder, FieldFinder.MultipleFieldsFinder, FieldFinder.NamedFieldFinder, FieldFinder.TypedFieldFinder, ReflectionFinder.ReflectionFinderWithParameters

public abstract class ReflectionFinder<T,U extends ReflectionFinder<T,U>> extends Object
Represents a class that can find reflection objects in classes.
  • Field Details

    • modifiers

      protected int modifiers
  • Constructor Details

    • ReflectionFinder

      protected ReflectionFinder()
    • ReflectionFinder

      protected ReflectionFinder(ReflectionFinder<?,?> other)
  • Method Details

    • get

      @CheckReturnValue @Contract(pure=true) public abstract T get()
      Retrieves the target reflection object(s) using the current configuration.

      This may throw an exception if the lookup hasn't been configured yet.

      Returns:
      The target reflection object(s) being searched for.
      Throws:
      NullPointerException - If the target reflection object(s) could not be found.
    • getNullable

      @CheckReturnValue @Contract(pure=true) @Nullable public abstract T getNullable()
      Retrieves the target reflection object(s) using the current configuration.

      This may throw an exception if the lookup hasn't been configured yet.

      Returns:
      The target reflection object(s) being searched for or null if no object(s) could be found.
    • withModifiers

      public U withModifiers(int... mods)
      See addModifiers(int...).

      Setting this to 0 will cause the finder to ignore the modifiers of the lookup object altogether (default).

      Parameters:
      mods - The set of modifiers to use as search constraint.
      Returns:
      The current finder instance.
    • addModifiers

      public U addModifiers(int... mods)
      Adds a set of modifiers to the current set of modifiers.

      The modifiers are used as search constraint, where the modifiers of the target object this finder is looking for have to be an exact match to the configured modifiers. This means that this will have to be an exact match, so a "public final" field cannot be found if the modifiers are set to just "public".

      Parameters:
      mods - The set of modifiers to use add to the current set of modifiers.
      Returns:
      The current finder instance.