Class ReflectionUtils

java.lang.Object
org.kohsuke.stapler.ReflectionUtils

public class ReflectionUtils extends Object
Author:
Kohsuke Kawaguchi
  • Constructor Details

    • ReflectionUtils

      public ReflectionUtils()
  • Method Details

    • getVmDefaultValueFor

      public static Object getVmDefaultValueFor(Class<?> type)
      Given the primitive type, returns the VM default value for that type in a boxed form. For reference types, return null.
    • union

      public static Annotation[] union(Annotation[] a, Annotation[] b)
      Merge two sets of annotations. If both contains the same annotation, the definition in 'b' overrides the definition in 'a' and shows up in the result
    • isOverridden

      public static boolean isOverridden(@NonNull Class<?> base, @NonNull Class<?> derived, @NonNull String methodName, @NonNull Class<?>... types)
      Checks whether the method defined on the base type with the given arguments is overridden in the given derived type.
      Parameters:
      base - The base type.
      derived - The derived type.
      methodName - The name of the method.
      types - The types of the arguments for the method.
      Returns:
      true when derived provides the specified method other than as inherited from base.
      Throws:
      IllegalArgumentException - When derived does not derive from base, or when base does not contain the specified method.
    • ifOverridden

      public static <T> T ifOverridden(Supplier<T> supplier, @NonNull Class<?> base, @NonNull Class<?> derived, @NonNull String methodName, @NonNull Class<?>... types)
      Calls the given supplier if the method defined on the base type with the given arguments is overridden in the given derived type.
      Parameters:
      supplier - The supplier to call if the method is indeed overridden.
      base - The base type.
      derived - The derived type.
      methodName - The name of the method.
      types - The types of the arguments for the method.
      Returns:
      true when derived provides the specified method other than as inherited from base.
      Throws:
      IllegalArgumentException - When derived does not derive from base, or when base does not contain the specified method.
      AbstractMethodError - If the derived class doesn't override the given method.
      Since:
      2.259