Package com.atlassian.bamboo.utils
Class BambooReflectionUtils
- java.lang.Object
-
- com.atlassian.bamboo.utils.BambooReflectionUtils
-
public class BambooReflectionUtils extends Object
Utility methods related to Java reflection API.
-
-
Constructor Summary
Constructors Constructor Description BambooReflectionUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static List<Field>
getAllDeclaredFields(@NotNull Class<?> clazz)
Returns all fields declared in the supplied class and its superclasses.static List<Method>
getAllDeclaredMethods(Class<?> clazz)
Returns all methods declared in the supplied class and its superclasses.static Class<?>
getSimpleType(@NotNull Class<?> aClass)
static boolean
hasCustomDeserialisation(Class<?> clazz)
Returns true if the class or any of its superclasses contain custom deserialisation method(s).static <T> T
instantiateQuietly(@NotNull Class<T> aClass)
Instantiates a class quietly, throwing all possible exceptions asRuntimeException
.static @NotNull String
method2SignatureString(@NotNull Method method)
Returns simplified signature of a method consisting of fully qualified class name, method name and list of argument types.
-
-
-
Method Detail
-
instantiateQuietly
@NotNull public static <T> T instantiateQuietly(@NotNull @NotNull Class<T> aClass)
Instantiates a class quietly, throwing all possible exceptions asRuntimeException
. UsesClass.newInstance()
method to instantiate class.- Type Parameters:
T
- type of the object to be instantiated- Parameters:
aClass
- class to be instantiated.- Returns:
- instantiated object of the given class
- Throws:
RuntimeException
- if any exceptions occurred while instantiating the class (e.g.InstantiationException
orIllegalAccessException
),RuntimeException
will be thrown as a wrapping exception.
-
getSimpleType
public static Class<?> getSimpleType(@NotNull @NotNull Class<?> aClass)
- Parameters:
aClass
-- Returns:
- simple type for arrays, for example for java.lang.String[] class it will return java.lang.String
-
getAllDeclaredFields
public static List<Field> getAllDeclaredFields(@NotNull @NotNull Class<?> clazz)
Returns all fields declared in the supplied class and its superclasses.
-
getAllDeclaredMethods
public static List<Method> getAllDeclaredMethods(Class<?> clazz)
Returns all methods declared in the supplied class and its superclasses.
-
hasCustomDeserialisation
public static boolean hasCustomDeserialisation(Class<?> clazz)
Returns true if the class or any of its superclasses contain custom deserialisation method(s). Note: does not take method visibility into account.
-
-