public final class ClassUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
appendClassHierarchy(List<Class<?>> res,
Class<?> clzin) |
static List<PropertyInfo> |
calculateProperties(Class<?> cl)
DO NOT USE - uncached calculation of a class's properties.
|
static <T> T |
callConstructor(Class<T> clz,
Class<?>[] formals,
Object... args) |
static Object |
callMethod(Object on,
String name,
Class[] formals,
Object... instances)
Calls the given method with the given parameters in a given class instance.
|
static Object |
callMethod(Object on,
String name,
Object... param)
Calls the given method with the given parameters in a given class instance.
|
static Object |
callObjectMethod(Object src,
String name,
Class<?>[] types,
Object... parameters)
Generic caller of a method using reflection.
|
static <T extends Annotation> |
findAnnotation(Annotation[] ar,
Class<T> clz)
Locates an annotation in an array of 'm, returns null if not found.
|
static <T extends Annotation> |
findAnnotationIncludingSuperClasses(Method annotatedMethod,
Class<T> annotationType)
Since annotations are not inherited, we do the extends search on super classed in order to be able to work also with annotations on inherited properties.
|
static Class<?> |
findCollectionType(Type genericType)
This tries to determine the value class for a property defined as some kind
of Collection<T> or T[].
|
static <T> Constructor<T> |
findConstructor(Class<T> clz,
Class<?>... formals) |
static Method |
findMethod(Class<?> clz,
String name,
Class<?>... param) |
static Method |
findMethod(Class<?> clz,
String name,
Object... param)
Tries to find a method that can be called using the specified parameters.
|
static PropertyInfo |
findPropertyInfo(Class<?> clz,
String property) |
static File |
findSrcFolderForModification(String packageName)
Finds source folder for package in the same project.
|
static File |
findSrcForModification(String className)
Finds sources for classes in the same project.
|
static URL[] |
findUrlsFor(ClassLoader loader)
Scan the classloader hierarchy and find all urls.
|
static List<Class<?>> |
getClassHierarchy(Class<?> clzin) |
static ClassInfo |
getClassInfo(Class<?> clz)
Get introspected bean information for the class.
|
static Object |
getClassValue(Object inst,
String name)
Retrieves a value from an object using introspection.
|
static String |
getMethodName(String prefix,
String property) |
static List<PropertyInfo> |
getProperties(Class<?> cl) |
static boolean |
isCollectionOrArrayType(Class<?> clz) |
static Class<?> |
loadClass(ClassLoader cl,
String cname) |
static <T> T |
loadInstance(ClassLoader cl,
Class<T> clz,
String className) |
static String |
propertyNameToJava(String in) |
static void |
propertyNameToJava(StringBuilder sb,
String in) |
@Nullable public static Object callMethod(@Nonnull Object on, @Nonnull String name, @Nonnull Object... param) throws Exception
on - name - objects - NoSuchMethodException - if no suitable method can be found in the object.Exception@Nullable public static Object callMethod(@Nonnull Object on, @Nonnull String name, @Nonnull Class[] formals, @Nonnull Object... instances) throws Exception
on - name - objects - NoSuchMethodException - if no suitable method can be found in the object.Exception@Nullable public static Method findMethod(@Nonnull Class<?> clz, @Nonnull String name, @Nonnull Class<?>... param)
@Nullable public static Method findMethod(@Nonnull Class<?> clz, @Nonnull String name, @Nonnull Object... param)
clz - name - param - @Nonnull public static ClassInfo getClassInfo(@Nonnull Class<?> clz)
clz - @Nullable public static PropertyInfo findPropertyInfo(@Nonnull Class<?> clz, @Nonnull String property)
@Nonnull public static List<PropertyInfo> getProperties(@Nonnull Class<?> cl)
@Nonnull public static List<PropertyInfo> calculateProperties(@Nonnull Class<?> cl)
cl - @Nonnull public static String getMethodName(@Nonnull String prefix, @Nonnull String property)
@Nullable public static Object callObjectMethod(@Nonnull Object src, @Nonnull String name, @Nonnull Class<?>[] types, @Nonnull Object... parameters) throws SQLException
src - name - ExceptionSQLExceptionpublic static final Class<?> loadClass(ClassLoader cl, String cname)
@Nonnull public static final <T> T loadInstance(@Nonnull ClassLoader cl, @Nonnull Class<T> clz, @Nonnull String className) throws Exception
Exception@Nullable public static <T extends Annotation> T findAnnotation(@Nonnull Annotation[] ar, @Nonnull Class<T> clz)
T - ar - clz - public static void propertyNameToJava(@Nonnull StringBuilder sb, @Nonnull String in)
@Nullable public static Class<?> findCollectionType(@Nonnull Type genericType)
genericType - public static void appendClassHierarchy(@Nonnull List<Class<?>> res, @Nonnull Class<?> clzin)
@Nonnull public static URL[] findUrlsFor(@Nonnull ClassLoader loader)
loader - @Nullable public static <T> Constructor<T> findConstructor(@Nonnull Class<T> clz, @Nonnull Class<?>... formals)
public static <T> T callConstructor(Class<T> clz, Class<?>[] formals, Object... args) throws Exception
Exception@Nullable public static File findSrcForModification(@Nonnull String className) throws Exception
className - classLoader - Exception@Nullable public static File findSrcFolderForModification(@Nonnull String packageName) throws Exception
className - classLoader - Exceptionpublic static final Object getClassValue(@Nonnull Object inst, @Nonnull String name) throws Exception
inst - name - Exception@Nullable public static <T extends Annotation> T findAnnotationIncludingSuperClasses(@Nonnull Method annotatedMethod, @Nonnull Class<T> annotationType)
annotatedMethod - annotationType - Copyright © 2017 etc.to. All rights reserved.