Class Methods
java.lang.Object
org.pushingpixels.substance.internal.contrib.randelshofer.quaqua.util.Methods
Methods contains convenience methods for method invocations using
java.lang.reflect.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Object
Invokes the specified accessible parameterless method if it exists.static Object
Invokes the specified setter method if it exists.static Object
Invokes the specified setter method if it exists.static Object
Invokes the specified method if it exists.static Object
Invokes the specified method if it exists.static Object
Invokes the specified setter method if it exists.static Object
Invokes the specified accessible method with a string parameter if it exists.static boolean
invokeGetter
(Object obj, String methodName, boolean defaultValue) Invokes the specified getter method if it exists.static int
invokeGetter
(Object obj, String methodName, int defaultValue) Invokes the specified getter method if it exists.static long
invokeGetter
(Object obj, String methodName, long defaultValue) Invokes the specified getter method if it exists.static Object
invokeGetter
(Object obj, String methodName, Object defaultValue) Invokes the specified getter method if it exists.static void
invokeIfExists
(Object obj, String methodName) Invokes the specified setter method if it exists.static void
invokeIfExists
(Object obj, String methodName, boolean newValue) Invokes the specified method if it exists.static void
invokeIfExists
(Object obj, String methodName, float newValue) Invokes the specified setter method if it exists.static void
invokeIfExists
(Object obj, String methodName, int newValue) Invokes the specified setter method if it exists.static void
invokeIfExists
(Object obj, String methodName, Class parameterClass, Object newValue) Invokes the specified setter method if it exists.static void
invokeIfExistsWithEnum
(Object obj, String methodName, String enumClassName, String enumValueName) Invokes the specified setter method if it exists.static Object
invokeStatic
(Class clazz, String methodName) Invokes the specified accessible parameterless method if it exists.static Object
invokeStatic
(Class clazz, String methodName, Class[] types, Object[] values) Invokes the specified static method if it exists.static Object
invokeStatic
(Class clazz, String methodName, Class type, Object value) Invokes the specified static method if it exists.static Object
invokeStatic
(String clazz, String methodName) Invokes the specified static parameterless method if it exists.static Object
invokeStatic
(String clazz, String methodName, Class[] types, Object[] values) Invokes the specified static method if it exists.static Object
Invokes the specified static method if it exists.static Object
invokeStatic
(String clazz, String methodName, Class type, Object value) Invokes the specified static method if it exists.static boolean
invokeStaticGetter
(Class clazz, String methodName, boolean defaultValue) Invokes the specified getter method if it exists.static Object
newInstance
(Class clazz, Class[] types, Object[] values) Invokes the specified constructor if it exists.
-
Method Details
-
invoke
Invokes the specified accessible parameterless method if it exists.- Parameters:
obj
- The object on which to invoke the method.methodName
- The name of the method.- Returns:
- The return value of the method.
- Throws:
NoSuchMethodException
-
invoke
public static Object invoke(Object obj, String methodName, String stringParameter) throws NoSuchMethodException Invokes the specified accessible method with a string parameter if it exists.- Parameters:
obj
- The object on which to invoke the method.methodName
- The name of the method.stringParameter
- The String parameter- Returns:
- The return value of the method or METHOD_NOT_FOUND.
- Throws:
NoSuchMethodException
-
invoke
public static Object invoke(Object obj, String methodName, Class[] types, Object[] values) throws NoSuchMethodException Invokes the specified method if it exists.- Parameters:
obj
- The object on which to invoke the method.methodName
- The name of the method.types
- The parameter types.values
- The parameter values.- Returns:
- The return value of the method.
- Throws:
NoSuchMethodException
-
invokeStatic
Invokes the specified accessible parameterless method if it exists.- Parameters:
clazz
- The class on which to invoke the method.methodName
- The name of the method.- Returns:
- The return value of the method or METHOD_NOT_FOUND.
- Throws:
NoSuchMethodException
-
invokeStatic
Invokes the specified static parameterless method if it exists.- Parameters:
clazz
- The class on which to invoke the method.methodName
- The name of the method.- Returns:
- The return value of the method.
- Throws:
NoSuchMethodException
-
invokeStatic
public static Object invokeStatic(Class clazz, String methodName, Class[] types, Object[] values) throws NoSuchMethodException Invokes the specified static method if it exists.- Parameters:
clazz
- The class on which to invoke the method.methodName
- The name of the method.types
- The parameter types.values
- The parameter values.- Returns:
- The return value of the method.
- Throws:
NoSuchMethodException
-
invokeStatic
public static Object invokeStatic(String clazz, String methodName, Class[] types, Object[] values) throws NoSuchMethodException Invokes the specified static method if it exists.- Parameters:
clazz
- The class on which to invoke the method.methodName
- The name of the method.types
- The parameter types.values
- The parameter values.- Returns:
- The return value of the method.
- Throws:
NoSuchMethodException
-
invokeStatic
public static Object invokeStatic(String clazz, String methodName, Class type, Object value) throws NoSuchMethodException Invokes the specified static method if it exists.- Parameters:
clazz
- The class on which to invoke the method.methodName
- The name of the method.type
- The parameter types.value
- The parameter values.- Returns:
- The return value of the method.
- Throws:
NoSuchMethodException
-
invokeStatic
public static Object invokeStatic(String clazz, String methodName, Class[] types, Object[] values, Object defaultValue) Invokes the specified static method if it exists.- Parameters:
clazz
- The class on which to invoke the method.methodName
- The name of the method.types
- The parameter types.values
- The parameter values.defaultValue
- The default value.- Returns:
- The return value of the method or the default value if the method does not exist or is not accessible.
-
invokeStatic
public static Object invokeStatic(Class clazz, String methodName, Class type, Object value) throws NoSuchMethodException Invokes the specified static method if it exists.- Parameters:
clazz
- The class on which to invoke the method.methodName
- The name of the method.type
- The parameter type.value
- The parameter value.- Returns:
- The return value of the method or the default value if the method does not exist or is not accessible.
- Throws:
NoSuchMethodException
-
invokeGetter
Invokes the specified getter method if it exists.- Parameters:
obj
- The object on which to invoke the method.methodName
- The name of the method.defaultValue
- This value is returned, if the method does not exist.- Returns:
- The value returned by the getter method or the default value.
-
invokeGetter
Invokes the specified getter method if it exists.- Parameters:
obj
- The object on which to invoke the method.methodName
- The name of the method.defaultValue
- This value is returned, if the method does not exist.- Returns:
- The value returned by the getter method or the default value.
-
invokeGetter
Invokes the specified getter method if it exists.- Parameters:
obj
- The object on which to invoke the method.methodName
- The name of the method.defaultValue
- This value is returned, if the method does not exist.- Returns:
- The value returned by the getter method or the default value.
-
invokeGetter
Invokes the specified getter method if it exists.- Parameters:
obj
- The object on which to invoke the method.methodName
- The name of the method.defaultValue
- This value is returned, if the method does not exist.- Returns:
- The value returned by the getter method or the default value.
-
invokeStaticGetter
Invokes the specified getter method if it exists.- Parameters:
clazz
- The class on which to invoke the method.methodName
- The name of the method.defaultValue
- This value is returned, if the method does not exist.- Returns:
- The value returned by the getter method or the default value.
-
invoke
public static Object invoke(Object obj, String methodName, boolean newValue) throws NoSuchMethodException Invokes the specified setter method if it exists.- Parameters:
obj
- The object on which to invoke the method.methodName
- The name of the method.- Throws:
NoSuchMethodException
-
invoke
public static Object invoke(Object obj, String methodName, int newValue) throws NoSuchMethodException Invokes the specified method if it exists.- Parameters:
obj
- The object on which to invoke the method.methodName
- The name of the method.- Throws:
NoSuchMethodException
-
invoke
public static Object invoke(Object obj, String methodName, float newValue) throws NoSuchMethodException Invokes the specified setter method if it exists.- Parameters:
obj
- The object on which to invoke the method.methodName
- The name of the method.- Throws:
NoSuchMethodException
-
invoke
public static Object invoke(Object obj, String methodName, Class clazz, Object newValue) throws NoSuchMethodException Invokes the specified setter method if it exists.- Parameters:
obj
- The object on which to invoke the method.methodName
- The name of the method.- Throws:
NoSuchMethodException
-
invokeIfExists
Invokes the specified setter method if it exists.- Parameters:
obj
- The object on which to invoke the method.methodName
- The name of the method.
-
invokeIfExists
Invokes the specified setter method if it exists.- Parameters:
obj
- The object on which to invoke the method.methodName
- The name of the method.
-
invokeIfExists
Invokes the specified setter method if it exists.- Parameters:
obj
- The object on which to invoke the method.methodName
- The name of the method.
-
invokeIfExists
Invokes the specified method if it exists.- Parameters:
obj
- The object on which to invoke the method.methodName
- The name of the method.
-
invokeIfExists
public static void invokeIfExists(Object obj, String methodName, Class parameterClass, Object newValue) Invokes the specified setter method if it exists.- Parameters:
obj
- The object on which to invoke the method.methodName
- The name of the method.
-
invokeIfExistsWithEnum
public static void invokeIfExistsWithEnum(Object obj, String methodName, String enumClassName, String enumValueName) Invokes the specified setter method if it exists.- Parameters:
obj
- The object on which to invoke the method.methodName
- The name of the method.
-
newInstance
public static Object newInstance(Class clazz, Class[] types, Object[] values) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException Invokes the specified constructor if it exists.- Parameters:
clazz
- The Class on which to invoke the constructor.types
- The parameter types of the constructor.values
- The parameter values of the constructor.- Throws:
NoSuchMethodException
InstantiationException
IllegalAccessException
InvocationTargetException
-