public abstract class ClassUtils
extends java.lang.Object
| 构造器和说明 |
|---|
ClassUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
addIgnoreAnnotationClass(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass) |
static void |
clearCache()
clear cache
|
static <T> java.util.Collection<java.lang.Class<?>> |
filter(java.util.function.Predicate<java.lang.Class<?>> predicate) |
static java.lang.Class<?> |
forName(java.lang.String name)
Load class
|
static java.util.Collection<java.lang.Class<?>> |
getAnnotatedClasses(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
Find class by annotation.
|
static <T extends java.lang.annotation.Annotation> |
getAnnotation(java.lang.reflect.AnnotatedElement annotatedElement,
java.lang.Class<T> annotationClass)
Get Annotation by proxy
|
static <T extends java.lang.annotation.Annotation> |
getAnnotation(java.lang.reflect.AnnotatedElement annotatedElement,
java.lang.Class<T> annotationClass,
java.lang.Class<? extends T> implClass)
Get Annotation by reflect
|
static <T extends java.lang.annotation.Annotation> |
getAnnotationArray(java.lang.reflect.AnnotatedElement annotatedElement,
java.lang.Class<T> annotationClass)
Get the array of
Annotation instance |
static <T extends java.lang.annotation.Annotation> |
getAnnotationArray(java.lang.reflect.AnnotatedElement annotatedElement,
java.lang.Class<T> annotationClass,
java.lang.Class<? extends T> implClass)
Get the array of
Annotation instance |
static <T extends java.lang.annotation.Annotation> |
getAnnotationAttributes(java.lang.reflect.AnnotatedElement annotatedElement,
java.lang.Class<T> annotationClass)
Get attributes the 'key-value' of annotations
|
static AnnotationAttributes |
getAnnotationAttributes(java.lang.annotation.Annotation annotation)
Get Annotation Attributes from an annotation instance
|
static <T extends java.lang.annotation.Annotation> |
getAnnotationAttributes(java.lang.annotation.Annotation annotation,
java.lang.Class<T> annotationClass)
Get target
AnnotationAttributes |
static <T extends java.lang.annotation.Annotation> |
getAnnotationProxy(java.lang.Class<T> annotationClass,
AnnotationAttributes attributes)
Get Annotation by proxy
|
static java.util.Collection<java.lang.Class<?>> |
getClassCache()
get all classes loaded in class path
|
static java.util.Collection<java.lang.Class<?>> |
getClasses(java.lang.String... packages)
Get
Collection of class under the packages |
static java.lang.ClassLoader |
getClassLoader() |
static java.lang.reflect.Field[] |
getFieldArray(java.lang.Class<?> targetClass)
Get all
Field array |
static java.util.Collection<java.lang.reflect.Field> |
getFields(java.lang.Class<?> targetClass)
Get all
Field list |
static java.util.Collection<java.lang.Class<?>> |
getImplClasses(java.lang.Class<?> superClass)
Get all child classes in class path
|
static java.util.Collection<java.lang.Class<?>> |
getImplClasses(java.lang.Class<?> superClass,
java.lang.String packageName)
Get all child classes in class path filter with package name
|
static java.lang.String[] |
getMethodArgsNames(java.lang.reflect.Method method)
Find method parameter list, and cache it.
|
static <T extends java.lang.annotation.Annotation> |
getTargetAnnotationAttributes(java.lang.Class<T> targetAnnotationType,
java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Use recursive to find the target annotation instance
|
static boolean |
isCollection(java.lang.Class<?> cls) |
static boolean |
isPresent(java.lang.String className) |
static void |
loadClassInJar(java.util.jar.JarEntry jarEntry,
java.lang.String packageName,
java.util.Collection<java.lang.Class<?>> scanClasses)
Load classes from a
JarEntry |
static <T> T |
newInstance(java.lang.Class<T> beanClass)
Get instance with bean class
|
static <T> T |
newInstance(java.lang.String beanClassName)
Get instance with bean class
|
static void |
scan(java.util.Collection<java.lang.Class<?>> scanClasses,
java.lang.String packageName) |
static java.util.Collection<java.lang.Class<?>> |
scan(java.lang.String... packages)
Scan class with given package.
|
static void |
setClassCache(java.util.Collection<java.lang.Class<?>> classes) |
static void |
setClassLoader(java.lang.ClassLoader classLoader) |
public static void addIgnoreAnnotationClass(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
public static final boolean isCollection(java.lang.Class<?> cls)
cls - public static boolean isPresent(java.lang.String className)
className - public static java.lang.Class<?> forName(java.lang.String name)
throws java.lang.ClassNotFoundException
name - a class full namejava.lang.ClassNotFoundException - when class could not be foundpublic static java.util.Collection<java.lang.Class<?>> getAnnotatedClasses(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
annotationClass - annotation classpublic static java.util.Collection<java.lang.Class<?>> getImplClasses(java.lang.Class<?> superClass)
superClass - super class or a interface classCollection of impl classpublic static java.util.Collection<java.lang.Class<?>> getImplClasses(java.lang.Class<?> superClass,
java.lang.String packageName)
superClass - super class or a interface classpackageName - package nameCollection of impl classpublic static final <T> java.util.Collection<java.lang.Class<?>> filter(java.util.function.Predicate<java.lang.Class<?>> predicate)
predicate - a non-interfering,
stateless
predicate to apply to each element to determine if it should be
includedpublic static java.util.Collection<java.lang.Class<?>> getClasses(java.lang.String... packages)
Collection of class under the packagespackages - package nameCollection of class under the packagespublic static java.util.Collection<java.lang.Class<?>> scan(java.lang.String... packages)
packages - the packages to scanpublic static void scan(java.util.Collection<java.lang.Class<?>> scanClasses,
java.lang.String packageName)
scanClasses - packageName - public static void loadClassInJar(java.util.jar.JarEntry jarEntry,
java.lang.String packageName,
java.util.Collection<java.lang.Class<?>> scanClasses)
JarEntryjarEntry - the entry of jarscanClasses - class setpublic static java.lang.String[] getMethodArgsNames(java.lang.reflect.Method method)
throws java.io.IOException
method - target methodjava.io.IOException - when could not access to the class filepublic static <T extends java.lang.annotation.Annotation> T[] getAnnotationArray(java.lang.reflect.AnnotatedElement annotatedElement,
java.lang.Class<T> annotationClass,
java.lang.Class<? extends T> implClass)
Annotation instanceannotatedElement - annotated elementannotationClass - target annotation classimplClass - impl classAnnotation instancepublic static <T extends java.lang.annotation.Annotation> T[] getAnnotationArray(java.lang.reflect.AnnotatedElement annotatedElement,
java.lang.Class<T> annotationClass)
Annotation instanceannotatedElement - annotated elementannotationClass - target annotation classAnnotation instancepublic static <T extends java.lang.annotation.Annotation> java.util.Collection<T> getAnnotation(java.lang.reflect.AnnotatedElement annotatedElement,
java.lang.Class<T> annotationClass,
java.lang.Class<? extends T> implClass)
annotatedElement - The annotated elementannotationClass - The annotation classimplClass - The implementation classCollection of Annotation instancepublic static AnnotationAttributes getAnnotationAttributes(java.lang.annotation.Annotation annotation)
annotation - annotation instanceAnnotationAttributespublic static <T extends java.lang.annotation.Annotation> java.util.Collection<T> getAnnotation(java.lang.reflect.AnnotatedElement annotatedElement,
java.lang.Class<T> annotationClass)
annotatedElement - The annotated elementannotationClass - The annotation classCollection of Annotation instancepublic static <T extends java.lang.annotation.Annotation> T getAnnotationProxy(java.lang.Class<T> annotationClass,
AnnotationAttributes attributes)
annotationClass - The annotation classattributes - The annotation attributes key-valueAnnotation instancepublic static <T extends java.lang.annotation.Annotation> java.util.Collection<AnnotationAttributes> getAnnotationAttributes(java.lang.reflect.AnnotatedElement annotatedElement, java.lang.Class<T> annotationClass)
annotatedElement - The annotated elementannotationClass - The annotation classpublic static <T extends java.lang.annotation.Annotation> AnnotationAttributes getAnnotationAttributes(java.lang.annotation.Annotation annotation, java.lang.Class<T> annotationClass)
AnnotationAttributesannotationClass - The annotation classannotation - The annotation instanceAnnotationAttributespublic static <T extends java.lang.annotation.Annotation> AnnotationAttributes getTargetAnnotationAttributes(java.lang.Class<T> targetAnnotationType, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
targetAnnotationType - target Annotation thyeannotationType - public static <T> T newInstance(java.lang.Class<T> beanClass)
beanClass - bean classpublic static <T> T newInstance(java.lang.String beanClassName)
beanClassName - bean class name stringpublic static java.util.Collection<java.lang.reflect.Field> getFields(java.lang.Class<?> targetClass)
Field listtargetClass - target classFieldpublic static java.lang.reflect.Field[] getFieldArray(java.lang.Class<?> targetClass)
Field arraytargetClass - target classField arraypublic static void clearCache()
public static void setClassLoader(java.lang.ClassLoader classLoader)
public static java.lang.ClassLoader getClassLoader()
public static java.util.Collection<java.lang.Class<?>> getClassCache()
public static void setClassCache(java.util.Collection<java.lang.Class<?>> classes)
Copyright © 2019 TODAY. All rights reserved.