Class ReflectUtil

java.lang.Object
org.barfuin.gradle.taskinfo.util.ReflectUtil

public final class ReflectUtil extends Object
Utility methods to access Gradle properties on objects reflectively.
  • Method Details

    • readField

      @Nonnull public static Object readField(@Nonnull Object pObject, String pDescription, @Nonnull List<String> pFieldNames)
    • readField

      @CheckForNull public static Object readField(@Nonnull Object pObject, String pDescription, @Nonnull List<String> pFieldNames, boolean pAllowNull)
    • hasField

      public static boolean hasField(Object pObject, String pFieldName)
    • getExecutionPlan

      @Nonnull public static Object getExecutionPlan(@Nonnull TaskExecutionGraph pTaskGraph)
    • callMethodIfPresent

      @CheckForNull public static Object callMethodIfPresent(@Nullable Object pObject, @Nonnull String pMethodName, @Nullable Object... pParameters)
      Call the given method on the given object if it exists and return the result.
      Parameters:
      pObject - an object
      pMethodName - the name of a parameterless method
      pParameters - the parameters to pass to the called method, or null / left out for none
      Returns:
      the method's return value. A result of null may mean that the method did not exist, or its return value was null, or its return type was void.
    • callScheduledNodesVistor

      public static void callScheduledNodesVistor(@Nullable Object pObject, @Nonnull BiConsumer<List<org.gradle.execution.plan.Node>,Set<org.gradle.execution.plan.Node>> pVisitor)
    • loadClassIfPossible

      @CheckForNull public static Class<?> loadClassIfPossible(@Nonnull String pFqcn)
    • isInstanceOf

      public static boolean isInstanceOf(@Nonnull String pSuperFqcn, @Nullable Object pObject)
      Tries to load the class determined by pSuperFqcn, and on success, determines if the given object is an instance of it.
      Parameters:
      pSuperFqcn - fully qualified class name of the potential superclass
      pObject - any object
      Returns:
      true if pSuperFqcn could be loaded and pObject is an instance of it; false if either is not the case