public class ReflectionUtils extends Object
Various utility functions to simplify reflection use cases.
This is primarily meant to be used with "safe" classes such that there shouldn't be a need to use AccessController to do priviledged actions.
Constructor and Description |
---|
ReflectionUtils() |
Modifier and Type | Method and Description |
---|---|
static Object |
invokeGetter(Object instance,
String methodName)
Invokes a ‘getter’ method of the given name on the given instance.
|
static boolean |
isClassPresent(String className,
Class context)
Checks if a class is present on the classpath
|
public static Object invokeGetter(Object instance, String methodName)
Invokes a ‘getter’ method of the given name on the given instance. The method is assumed to be a basic getter with no parameters. If no method exists, or there is an problem invoking the method, null will be returned.
instance
- The instance to invoke the method on.methodName
- The method name, if it exists.public static boolean isClassPresent(String className, Class context)
Checks if a class is present on the classpath
className
- The name of the class to check the presence ofcontext
- The method name, if it exists.Copyright © 2016–2023. All rights reserved.