public final class ClassUtils extends Object
| Constructor and Description |
|---|
ClassUtils() |
| Modifier and Type | Method and Description |
|---|---|
static <T> int |
compareTo(T obj1,
T obj2,
Function<T,? extends Comparable<?>>... getters)
Helper function to implement compare interfaces
|
static <T> boolean |
equals(T obj1,
Object obj2,
Function<T,?>... getters)
Helper function to implement equals by given getter functions
|
static Set<String> |
getClassNamesFromDirectory(File directory)
Returns class names from directory.
|
static Set<String> |
getClassNamesFromJarFile(File file)
Method that returns all class file names from given jar file
|
static Set<String> |
getClassNamesFromPackage(File directory,
String packageName,
boolean recursive)
Recursive method used to find all classes in a given directory and
subdirs.
|
static Class<?> |
getNonPrimitiveClass(Class<?> clazz) |
static Class<?> |
getPrimitiveClass(Class<?> clazz) |
static Collection<Class<?>> |
getPrimitveClasses() |
static <T> String |
getString(T obj,
Function<T,?>... getters)
Helper function for toString function
|
static <T> int |
hashCode(T obj,
Function<T,?>... getters)
Helper function to calculate a hashcode from selected getter functions
null values are treated as 0
|
static boolean |
isPackageMember(Class<?> clazz,
String packageName)
Checks if class in member of the package
|
static boolean |
isPackageMember(String className,
String packageName)
Checks if classNames belongs to package
|
static boolean |
isSubclass(Class<?> a,
Class<?> b)
Return true if class a is either equivalent to class b, or if class a is
a subclass of class b, i.e. if a either "extends" or "implements" b.
|
@SafeVarargs public static final <T> String getString(T obj, Function<T,?>... getters)
obj - getters - @SafeVarargs public static final <T> int hashCode(T obj, Function<T,?>... getters)
null values are treated as 0
obj - getters - @SafeVarargs public static final <T> boolean equals(T obj1, Object obj2, Function<T,?>... getters)
obj1 - obj2 - getters - @SafeVarargs public static final <T> int compareTo(T obj1, T obj2, Function<T,? extends Comparable<?>>... getters)
obj1 - obj2 - getters - Comparable#compareTo(Object)}public static boolean isSubclass(Class<?> a, Class<?> b)
a - classb - classpublic static boolean isPackageMember(Class<?> clazz, String packageName)
clazz - class to checkpackageName - packagepublic static boolean isPackageMember(String className, String packageName)
className - class namepackageName - packagepublic static Set<String> getClassNamesFromDirectory(File directory) throws IllegalArgumentException
directory - folder with class filesIllegalArgumentException - if specified file is not directory or does not existsNullPointerException - if directory is nullpublic static Set<String> getClassNamesFromPackage(File directory, String packageName, boolean recursive)
directory - The base directorypackageName - The package name for classes found inside the base directoryrecursive - include subpackages or notpublic static Set<String> getClassNamesFromJarFile(File file) throws IOException
file - jar fileIOException - if something went wrongIllegalArgumentException - if file doesn't exists or is not jar fileNullPointerException - if file is nullpublic static Collection<Class<?>> getPrimitveClasses()
Copyright © 2014–2015. All rights reserved.