Package org.kohsuke.stapler
Class ReflectionUtils
java.lang.Object
org.kohsuke.stapler.ReflectionUtils
- Author:
- Kohsuke Kawaguchi
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectgetVmDefaultValueFor(Class<?> type) Given the primitive type, returns the VM default value for that type in a boxed form.static <T> TifOverridden(Supplier<T> supplier, Class<?> base, Class<?> derived, String methodName, 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.static booleanisOverridden(Class<?> base, Class<?> derived, String methodName, Class<?>... types) Checks whether the method defined on the base type with the given arguments is overridden in the given derived type.static Annotation[]union(Annotation[] a, Annotation[] b) Merge two sets of annotations.
-
Constructor Details
-
ReflectionUtils
public ReflectionUtils()
-
-
Method Details
-
getVmDefaultValueFor
Given the primitive type, returns the VM default value for that type in a boxed form. For reference types, return null. -
union
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:
truewhenderivedprovides the specified method other than as inherited frombase.- Throws:
IllegalArgumentException- Whenderiveddoes not derive frombase, or whenbasedoes 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:
truewhenderivedprovides the specified method other than as inherited frombase.- Throws:
IllegalArgumentException- Whenderiveddoes not derive frombase, or whenbasedoes not contain the specified method.AbstractMethodError- If the derived class doesn't override the given method.- Since:
- 2.259
-