Package org.kohsuke.stapler
Class ReflectionUtils
java.lang.Object
org.kohsuke.stapler.ReflectionUtils
- Author:
- Kohsuke Kawaguchi
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Object
getVmDefaultValueFor
(Class<?> type) Given the primitive type, returns the VM default value for that type in a boxed form.static <T> T
ifOverridden
(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 boolean
isOverridden
(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:
true
whenderived
provides the specified method other than as inherited frombase
.- Throws:
IllegalArgumentException
- Whenderived
does not derive frombase
, or whenbase
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
whenderived
provides the specified method other than as inherited frombase
.- Throws:
IllegalArgumentException
- Whenderived
does not derive frombase
, or whenbase
does not contain the specified method.AbstractMethodError
- If the derived class doesn't override the given method.- Since:
- 2.259
-