Class Reflections

java.lang.Object
studio.mevera.imperat.util.reflection.Reflections

public final class Reflections extends Object
  • Constructor Details

    • Reflections

      public Reflections()
  • Method Details

    • getField

      public static <T> FieldAccessor<T> getField(Class<?> target, String name, Class<T> fieldType)
      Retrieve a field accessor for a specific field valueType and name.
      Parameters:
      target - - the targetToLoad valueType.
      name - - the name of the field, or NULL to ignore.
      fieldType - - a compatible field valueType.
      Returns:
      The field accessor.
    • getField

      public static <T> FieldAccessor<T> getField(String className, String name, Class<T> fieldType)
      Retrieve a field accessor for a specific field valueType and name.
      Parameters:
      className - - lookup name of the class, see getClass(String).
      name - - the name of the field, or NULL to ignore.
      fieldType - - a compatible field valueType.
      Returns:
      The field accessor.
    • getField

      public static <T> FieldAccessor<T> getField(Class<?> target, Class<T> fieldType)
      Retrieve a field accessor for a specific field valueType and name.
      Parameters:
      target - - the targetToLoad valueType.
      fieldType - - a compatible field valueType.
      Returns:
      The field accessor.
    • getField

      public static <T> FieldAccessor<T> getField(Class<?> target, Class<T> fieldType, int index)
      Retrieve a field accessor for a specific field valueType and name.
      Parameters:
      target - - the targetToLoad valueType.
      fieldType - - a compatible field valueType.
      index - - the number of compatible fields to skip.
      Returns:
      The field accessor.
    • getField

      public static <T> FieldAccessor<T> getField(String className, Class<T> fieldType, int index)
      Retrieve a field accessor for a specific field valueType and name.
      Parameters:
      className - - lookup name of the class, see getClass(String).
      fieldType - - a compatible field valueType.
      index - - the number of compatible fields to skip.
      Returns:
      The field accessor.
    • findClass

      public static boolean findClass(Supplier<Class<?>> classSupplier)
      Returns:
      false if the Class was NOT found
    • findClass

      public static boolean findClass(String... paths)
      Finds any Class of the provided paths
      Parameters:
      paths - all possible class paths
      Returns:
      false if the Class was NOT found
    • getClass

      public static Class<?> getClass(@NotNull @NotNull String path)
      A nullable Class.forName(String) instead of throwing exceptions
      Returns:
      null if the Class was NOT found
    • getConstructor

      public static Constructor<?> getConstructor(@NotNull @NotNull Class<?> clazz, Class<?>... classes)
      A nullable Class.getDeclaredConstructor(Class[]) instead of throwing exceptions
      Returns:
      null if the Constructor was NOT found