public final class ClassUtils extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ClassUtils.BetterClassLoader
Loads classes from files on the server's hard disk.
|
static class |
ClassUtils.ClassComparator |
static class |
ClassUtils.ExtensionFilter |
Modifier and Type | Field and Description |
---|---|
static String |
CLASS_EXTENSION |
static String |
JAVA_EXTENSION |
Constructor and Description |
---|
ClassUtils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
classImplements(Class<?> clazz,
Class<?> interfaceType) |
static String |
compile(String fileName)
Compiles the .java source file with the given file name,
and returns the file name of the newly compiled .class file.
|
static <T> List<Class<? extends T>> |
getClasses(Class<T> superClass,
String folderName) |
static List<String> |
getClassPathFolders() |
static Set<String> |
getFieldNames(Class<?> clazz)
Returns a set of names of all fields in the given class.
|
static Set<Field> |
getFields(Class<?> clazz,
Class<?> type) |
static Set<Field> |
getFields(Class<?> clazz,
Class<?> type,
Class<?> parameterizedType) |
static Set<Field> |
getFields(Class<?> clazz,
Class<?> type,
Class<?> parameterizedType,
boolean allowSubtype) |
static Set<Field> |
getFields(Class<?> clazz,
Set<Class<?>> types,
Class<?> parameterizedType,
boolean allowSubtype) |
static List<Class<?>> |
getFieldTypes(Class<?> clazz)
Returns a set of types of all fields in the given class.
|
static String |
getFirstClassPathFolder() |
static Set<String> |
getMethodNames(Class<?> clazz)
Returns a set of names of all methods in the given class.
|
static Set<Constructor<?>> |
getNonPrivateConstructors(Class<?> clazz)
Returns a set of names of all methods in the given class that are not private.
|
static Set<String> |
getNonPrivateFieldNames(Class<?> clazz)
Returns a set of names of all fields in the given class that are not private.
|
static Set<String> |
getNonPrivateFieldNames(Class<?> clazz,
boolean allowProtected) |
static Set<String> |
getNonPrivateFieldNames(String className)
Returns a set of names of all fields in class with the given name that are not private.
|
static Set<String> |
getNonPrivateFieldNames(String className,
boolean allowProtected) |
static Set<String> |
getNonPrivateMethodNames(Class<?> clazz) |
static Set<String> |
getNonPrivateMethodNames(Class<?> clazz,
boolean allowProtected)
Returns a set of names of all methods in the given class that are not private.
|
static Set<Method> |
getNonPrivateMethods(Class<?> clazz)
Returns a set of names of all methods in the given class that are not private.
|
static boolean |
hasMain(Class<?> clazz) |
static boolean |
isInnerClass(Class<?> clazz) |
static boolean |
isInnerClass(String className) |
static Class<?> |
loadClass(String fileName) |
static String |
readAndRename(String oldClassName,
String newClassName) |
static String |
readAndRename(String fileName,
String oldClassName,
String newClassName) |
static boolean |
reflectionEquals(Object o1,
Object o2) |
static String |
renameAndWriteJavaFile(String fileText,
String oldClassName,
String newClassName,
boolean useTempFolder) |
static void |
runMain(Class<?> clazz) |
static void |
runMain(Class<?> clazz,
String[] args) |
static String |
sanitizeClassName(String text) |
static String |
stripPackages(Class<?> clazz) |
static String |
stripPackages(String className) |
static String |
writeAndCompile(String fileText,
String className,
boolean useTempFolder) |
static Class<?> |
writeAndLoadClass(String fileText,
String className,
boolean useTempFolder) |
public static final String CLASS_EXTENSION
public static final String JAVA_EXTENSION
public static boolean hasMain(Class<?> clazz)
public static void runMain(Class<?> clazz) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException
public static void runMain(Class<?> clazz, String[] args) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException
public static Set<Field> getFields(Class<?> clazz, Class<?> type, Class<?> parameterizedType)
public static Set<Field> getFields(Class<?> clazz, Class<?> type, Class<?> parameterizedType, boolean allowSubtype)
public static Set<Field> getFields(Class<?> clazz, Set<Class<?>> types, Class<?> parameterizedType, boolean allowSubtype)
public static Set<String> getFieldNames(Class<?> clazz)
public static List<Class<?>> getFieldTypes(Class<?> clazz)
public static String getFirstClassPathFolder()
public static Set<String> getNonPrivateFieldNames(String className)
public static Set<String> getNonPrivateFieldNames(String className, boolean allowProtected)
public static Set<String> getNonPrivateFieldNames(Class<?> clazz)
public static Set<String> getNonPrivateFieldNames(Class<?> clazz, boolean allowProtected)
public static Set<String> getNonPrivateMethodNames(Class<?> clazz, boolean allowProtected)
public static Set<Method> getNonPrivateMethods(Class<?> clazz)
public static Set<Constructor<?>> getNonPrivateConstructors(Class<?> clazz)
public static Set<String> getMethodNames(Class<?> clazz)
public static boolean isInnerClass(Class<?> clazz)
public static boolean isInnerClass(String className)
public static String writeAndCompile(String fileText, String className, boolean useTempFolder) throws IOException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException
public static Class<?> writeAndLoadClass(String fileText, String className, boolean useTempFolder) throws IOException, ClassNotFoundException, IllegalAccessException, InvocationTargetException, NoSuchMethodException
public static String compile(String fileName) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException
public static <T> List<Class<? extends T>> getClasses(Class<T> superClass, String folderName)
public static Class<?> loadClass(String fileName) throws ClassNotFoundException
ClassNotFoundException
public static String readAndRename(String oldClassName, String newClassName) throws IOException
IOException
public static String readAndRename(String fileName, String oldClassName, String newClassName) throws IOException
IOException
public static String renameAndWriteJavaFile(String fileText, String oldClassName, String newClassName, boolean useTempFolder)