Class ClassUtils
java.lang.Object
org.frankframework.util.ClassUtils
A collection of class management utility methods.
- Author:
- Johan Verrips
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringclassNameOf(@Nullable Object o) Returns the ClassName of the object (without package name), likenameOf(Object), but without [name] suffix for aHasName.static <T> @Nullable TconvertToType(Class<T> type, String value) Converts the String value to the supplied type.getClassInfo(@Nullable Class<?> clazz, @Nullable ClassLoader classLoader) getClassInfoList(Class<?> clazz) static Constructor<?> getConstructorOnType(Class<?> clas, Class<?>[] parameterTypes) Retrieves the constructor of a class, based on the parametersstatic @Nullable ObjectgetDeclaredFieldValue(Object o, Class<?> c, String name) static @Nullable ObjectgetDeclaredFieldValue(Object o, String name) static @Nullable URLgetResourceURL(String resource) Attempts to locate the resource, first on the local class-path, if no match, it attempts to find the resource as file-path.static ObjectinvokeGetter(Object o, String name, boolean forceAccess) static voidinvokeSetter(Object clazz, Method method, String valueToSet) Throws IllegalArgumentException if the argument type is incompatible Throws IllegalStateException if the argument cannot be set on the target beanstatic voidinvokeSetter(Object o, String name, Object value) static voidinvokeSetter(Object o, String name, Object value, Class<?> clazz) static voidinvokeSetters(Object clazz, Properties properties) static booleanisClassPresent(String className) static Class<?> Load a class given its name.static StringReturns the ClassName or BeanName of the object without the package name AND includes a [name] suffix for aHasNamebean.static <T> TnewInstance(Class<T> clazz) static <T> TnewInstance(String className, Class<T> expectedType) Create a new instance given a class name.
-
Method Details
-
getResourceURL
Attempts to locate the resource, first on the local class-path, if no match, it attempts to find the resource as file-path.- Throws:
FileNotFoundException- in case the resource name is invalid
-
getConstructorOnType
public static Constructor<?> getConstructorOnType(Class<?> clas, Class<?>[] parameterTypes) throws NoSuchMethodException Retrieves the constructor of a class, based on the parameters- Throws:
NoSuchMethodException
-
newInstance
public static <T> T newInstance(String className, Class<T> expectedType) throws ReflectiveOperationException, SecurityException Create a new instance given a class name. The constructor of the class does NOT have parameters.- Parameters:
className- The class name to loadexpectedType- The class type to expect- Returns:
- A new instance
- Throws:
ReflectiveOperationException- If an instantiation error occursSecurityException- If a security violation occurs
-
newInstance
public static <T> T newInstance(Class<T> clazz) throws ReflectiveOperationException, SecurityException -
loadClass
Load a class given its name. We want to use a known ClassLoader.- Parameters:
className- A class name- Returns:
- The class pointed to by
className - Throws:
ClassNotFoundException- If a loading error occurs
-
nameOf
-
classNameOf
Returns the ClassName of the object (without package name), likenameOf(Object), but without [name] suffix for aHasName. -
isClassPresent
-
invokeSetters
-
invokeSetter
-
convertToType
public static <T> @Nullable T convertToType(Class<T> type, String value) throws IllegalArgumentException Converts the String value to the supplied type.- Parameters:
type- to convert the input value to- Returns:
- The converted value, of type <T>.
- Throws:
IllegalArgumentException- (or NumberFormatException) when the value cannot be converted to the given type T.
-
invokeSetter
public static void invokeSetter(Object o, String name, Object value) throws SecurityException, ReflectiveOperationException, IllegalArgumentException -
invokeSetter
public static void invokeSetter(Object o, String name, Object value, Class<?> clazz) throws SecurityException, ReflectiveOperationException, IllegalArgumentException -
invokeGetter
public static Object invokeGetter(Object o, String name, boolean forceAccess) throws SecurityException, ReflectiveOperationException, IllegalArgumentException -
getDeclaredFieldValue
public static @Nullable Object getDeclaredFieldValue(Object o, Class<?> c, String name) throws IllegalArgumentException, SecurityException, NoSuchFieldException -
getDeclaredFieldValue
public static @Nullable Object getDeclaredFieldValue(Object o, String name) throws IllegalArgumentException, SecurityException, NoSuchFieldException -
getClassInfoList
-
getClassInfo
public static Map<String,Object> getClassInfo(@Nullable Class<?> clazz, @Nullable ClassLoader classLoader)
-