public final class ReflectUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
callMethod(Object object,
String methodName,
Object... arguments)
Calls object's method with the specified name and arguments.
|
static <T> List<T> |
callMethods(List<?> objects,
String methodName,
Object... arguments)
Returns list of results returned by called methods.
|
static Object[] |
callMethods(Object[] objects,
String methodName,
Object... arguments)
Returns an array of results returned by called methods.
|
static <T> T |
callMethodSafely(Object object,
String methodName,
Object... arguments)
Returns result given by called method.
|
static <T> List<T> |
callMethodsSafely(List<?> objects,
String methodName,
Object... arguments)
Returns list of results returned by called methods.
|
static Object[] |
callMethodsSafely(Object[] objects,
String methodName,
Object... arguments)
Returns an array of results returned by called methods.
|
static <T> T |
callStaticMethod(Class theClass,
String methodName,
Object... arguments)
Returns result of called static method.
|
static <T> T |
callStaticMethod(String canonicalClassName,
String methodName,
Object... arguments)
Returns result of called static method.
|
static <T> T |
callStaticMethodSafely(Class theClass,
String methodName,
Object... arguments)
Returns result of called static method.
|
static <T> T |
callStaticMethodSafely(String canonicalClassName,
String methodName,
Object... arguments)
Returns result of called static method.
|
static <T extends Cloneable> |
clone(T object)
Returns cloned object.
|
static <T extends Cloneable> |
cloneSafely(T object)
Returns cloned object.
|
static boolean |
containsInClassOrSuperclassName(Class theClass,
String text)
Returns whether one of superclasses contains specified text in its name or not.
|
static <T> T |
createInstance(Class theClass,
Object... arguments)
Returns newly created class instance.
|
static <T> T |
createInstance(String canonicalClassName,
Object... arguments)
Returns newly created class instance.
|
static <T> T |
createInstanceSafely(Class theClass,
Object... arguments)
Returns newly created class instance.
|
static <T> T |
createInstanceSafely(String canonicalClassName,
Object... arguments)
Returns newly created class instance.
|
static Class |
getCallerClass()
Returns method caller class.
|
static Class |
getCallerClass(int additionalDepth)
Returns method caller class.
|
static <T> Class<T> |
getClass(String canonicalName)
Returns class for the specified canonical name.
|
static String |
getClassFileName(Class classType)
Returns class name with ".class" extension in the end.
|
static String |
getClassFileName(Object classObject)
Returns class name with ".class" extension in the end.
|
static String |
getClassName(Class classType)
Returns class name.
|
static String |
getClassName(Object classObject)
Returns class name.
|
static String[] |
getClassPackages(Class classType)
Returns class packages.
|
static String[] |
getClassPackages(Object classObject)
Returns class packages.
|
static <T> Class<T> |
getClassSafely(String canonicalName)
Returns class for the specified canonical name.
|
static Class[] |
getClassTypes(Object[] arguments)
Returns an array of argument class types.
|
static Class |
getClosestSuperclass(Class class1,
Class class2)
|
static Class |
getClosestSuperclass(Object object1,
Object object2)
Returns closest superclass for both of the specified classes.
|
static String |
getCompleteClassName(Class classType)
Returns complete class name that includes enclosing class name if one exists.
|
static String |
getCompleteClassName(Object classObject)
Returns complete class name that includes enclosing class name if one exists.
|
static Constructor |
getConstructor(Class theClass,
Class... parameterTypes)
Returns class constructor for the specified argument types.
|
static Object |
getDefaultPrimitiveValue(Class<?> type)
Returns default primitive type value.
|
static Field |
getField(Class<?> classType,
String fieldName)
Returns specified class field.
|
static Method |
getFieldGetter(Class aClass,
String field)
Returns field getter method by popular method naming pattern.
|
static Method |
getFieldGetter(Object object,
String field)
Returns field getter method by popular method naming pattern.
|
static List<Field> |
getFields(Class clazz)
Returns all fields in the specified class and all of its superclasses.
|
static List<Field> |
getFields(Class clazz,
ModifierType... ignoredModifiers)
Returns all fields in the specified class and all of its superclasses.
|
static List<Field> |
getFields(Object object)
Returns all fields in the specified object class and all of its superclasses.
|
static List<Field> |
getFields(Object object,
ModifierType... ignoredModifiers)
Returns all fields in the specified object class and all of its superclasses.
|
static Field |
getFieldSafely(Class classType,
String fieldName)
Returns specified class field.
|
static Class<?> |
getFieldType(Class classType,
String fieldName)
Returns specified class field's type.
|
static Class<?> |
getFieldTypeSafely(Class classType,
String fieldName)
Returns specified class field's type.
|
static <T> T |
getFieldValue(Object object,
String fieldName)
Returns object field value.
|
static <T> T |
getFieldValueSafely(Object object,
String fieldName)
Returns object field value.
|
static String |
getGetterMethodName(String field)
Returns getter method name for the specified field.
|
static <T> Class<T> |
getInnerClass(Class fromClass,
String innerClassName)
Returns inner class with the specified name.
|
static <T> Class<T> |
getInnerClass(String fromClassName,
String innerClassName)
Returns inner class with the specified name.
|
static <T> Class<T> |
getInnerClassSafely(Class fromClass,
String innerClassName)
Returns inner class with the specified name.
|
static <T> Class<T> |
getInnerClassSafely(String fromClassName,
String innerClassName)
Returns inner class with the specified name.
|
static String |
getIsGetterMethodName(String field)
Returns "is" getter method name for the specified field.
|
static String |
getJavaClassName(Class classType)
Returns class name with ".java" extension in the end.
|
static String |
getJavaClassName(Object classObject)
Returns class name with ".java" extension in the end.
|
static Method |
getMethod(Class aClass,
String methodName,
Object... arguments)
Returns object's method with the specified name and arguments.
|
static Method |
getMethod(Object object,
String methodName,
Object... arguments)
Returns object's method with the specified name and arguments.
|
static Method |
getMethodSafely(Class aClass,
String methodName,
Object... arguments)
Returns object's method with the specified name and arguments.
|
static Method |
getMethodSafely(Object object,
String methodName,
Object... arguments)
Calls object's method with the specified name and arguments.
|
static String[] |
getPackages(String packageName)
Returns packages names.
|
static String |
getSetterMethodName(String field)
Returns setter method name for the specified field.
|
static <T> T |
getStaticFieldValue(Class classType,
String fieldName)
Returns static field value from the specified class.
|
static <T> T |
getStaticFieldValueSafely(Class classType,
String fieldName)
Returns static field value from the specified class.
|
static boolean |
hasAllOfModifiers(Class clazz,
Collection<ModifierType> modifiers)
Returns whether or not
Class has all of the specified modifiers. |
static boolean |
hasAllOfModifiers(Class clazz,
ModifierType... modifiers)
Returns whether or not
Class has all of the specified modifiers. |
static boolean |
hasAllOfModifiers(Field field,
Collection<ModifierType> modifiers)
Returns whether or not
Field has all of the specified modifiers. |
static boolean |
hasAllOfModifiers(Field field,
ModifierType... modifiers)
Returns whether or not
Field has all of the specified modifiers. |
static boolean |
hasAllOfModifiers(Method method,
Collection<ModifierType> modifiers)
Returns whether or not
Method has all of the specified modifiers. |
static boolean |
hasAllOfModifiers(Method method,
ModifierType... modifiers)
Returns whether or not
Method has all of the specified modifiers. |
static boolean |
hasAnyOfModifiers(Class clazz,
Collection<ModifierType> modifiers)
Returns whether or not
Class has any of the specified modifiers. |
static boolean |
hasAnyOfModifiers(Class clazz,
ModifierType... modifiers)
Returns whether or not
Class has any of the specified modifiers. |
static boolean |
hasAnyOfModifiers(Field field,
Collection<ModifierType> modifiers)
Returns whether or not
Field has any of the specified modifiers. |
static boolean |
hasAnyOfModifiers(Field field,
ModifierType... modifiers)
Returns whether or not
Field has any of the specified modifiers. |
static boolean |
hasAnyOfModifiers(Method method,
Collection<ModifierType> modifiers)
Returns whether or not
Method has any of the specified modifiers. |
static boolean |
hasAnyOfModifiers(Method method,
ModifierType... modifiers)
Returns whether or not
Method has any of the specified modifiers. |
static boolean |
hasMethod(Class aClass,
String methodName,
Object... arguments)
Returns whether method with the specified name and arguments exists in the specified class.
|
static boolean |
hasMethod(Object object,
String methodName,
Object... arguments)
Returns whether method with the specified name and arguments exists in the specified object.
|
static boolean |
hasNoneOfModifiers(Class clazz,
Collection<ModifierType> modifiers)
Returns whether or not
Class has none of the specified modifiers. |
static boolean |
hasNoneOfModifiers(Class clazz,
ModifierType... modifiers)
Returns whether or not
Class has none of the specified modifiers. |
static boolean |
hasNoneOfModifiers(Field field,
Collection<ModifierType> modifiers)
Returns whether or not
Field has none of the specified modifiers. |
static boolean |
hasNoneOfModifiers(Field field,
ModifierType... modifiers)
Returns whether or not
Field has none of the specified modifiers. |
static boolean |
hasNoneOfModifiers(Method method,
Collection<ModifierType> modifiers)
Returns whether or not
Method has none of the specified modifiers. |
static boolean |
hasNoneOfModifiers(Method method,
ModifierType... modifiers)
Returns whether or not
Method has none of the specified modifiers. |
static boolean |
isAssignable(Class type,
Class from)
Returns whether first type is assignable from second one or not.
|
static boolean |
isPrimitive(Class<?> type)
Returns whether or not specified class type is primitive.
|
static boolean |
isPrimitive(Object object)
Returns whether or not specified object has primitive type.
|
static boolean |
isSafeMethodsLoggingEnabled()
Returns whether should allow safe methods to log errors or not.
|
static Class |
loadClass(String canonicalClassName)
Returns class loaded for the specified canonical class name.
|
static void |
setFieldValue(Object object,
Field field,
Object value)
Applies specified value to object field.
|
static void |
setFieldValue(Object object,
String fieldName,
Object value)
Applies specified value to object field.
|
static boolean |
setFieldValueSafely(Object object,
Field field,
Object value)
Applies specified value to object field.
|
static boolean |
setFieldValueSafely(Object object,
String field,
Object value)
Applies specified value to object field.
|
static void |
setSafeMethodsLoggingEnabled(boolean enabled)
Sets whether should allow safe methods to log errors or not.
|
static void |
setStaticFieldValue(Class classType,
String fieldName,
Object value)
Applies specified value to static class field.
|
static boolean |
setStaticFieldValueSafely(Class classType,
String field,
Object value)
Applies specified value to static class field.
|
public static boolean isSafeMethodsLoggingEnabled()
true if should allow safe methods to log errors, false otherwisepublic static void setSafeMethodsLoggingEnabled(boolean enabled)
enabled - whether should allow safe methods to log errors or not@Nullable public static <T> Class<T> getClassSafely(@NotNull String canonicalName)
T - class typecanonicalName - class canonical name@NotNull public static <T> Class<T> getClass(@NotNull String canonicalName) throws ClassNotFoundException
T - class typecanonicalName - class canonical nameClassNotFoundException - if class was not foundpublic static <T> Class<T> getInnerClassSafely(Class fromClass, String innerClassName)
T - inner class typefromClass - class to look for the inner classinnerClassName - inner class namepublic static <T> Class<T> getInnerClassSafely(String fromClassName, String innerClassName)
T - inner class typefromClassName - name of the class to look for the inner classinnerClassName - inner class namepublic static <T> Class<T> getInnerClass(Class fromClass, String innerClassName) throws ClassNotFoundException
T - inner class typefromClass - class to look for the inner classinnerClassName - inner class nameClassNotFoundException - if inner class was not foundpublic static <T> Class<T> getInnerClass(String fromClassName, String innerClassName) throws ClassNotFoundException
T - inner class typefromClassName - name of the class to look for the inner classinnerClassName - inner class nameClassNotFoundException - if inner class was not foundpublic static Class getCallerClass()
public static Class getCallerClass(int additionalDepth)
additionalDepth - additional methods depthpublic static List<Field> getFields(Object object)
object - object to find fields forpublic static List<Field> getFields(Class clazz)
clazz - class to find fields forpublic static List<Field> getFields(Object object, ModifierType... ignoredModifiers)
object - object to find fields forignoredModifiers - modifiers of fields to ignorepublic static List<Field> getFields(Class clazz, ModifierType... ignoredModifiers)
clazz - class to find fields forignoredModifiers - modifiers of fields to ignorepublic static boolean hasAnyOfModifiers(Class clazz, ModifierType... modifiers)
Class has any of the specified modifiers.public static boolean hasAnyOfModifiers(Class clazz, Collection<ModifierType> modifiers)
Class has any of the specified modifiers.public static boolean hasAllOfModifiers(Class clazz, ModifierType... modifiers)
Class has all of the specified modifiers.public static boolean hasAllOfModifiers(Class clazz, Collection<ModifierType> modifiers)
Class has all of the specified modifiers.public static boolean hasNoneOfModifiers(Class clazz, ModifierType... modifiers)
Class has none of the specified modifiers.public static boolean hasNoneOfModifiers(Class clazz, Collection<ModifierType> modifiers)
Class has none of the specified modifiers.public static boolean hasAnyOfModifiers(Method method, ModifierType... modifiers)
Method has any of the specified modifiers.public static boolean hasAnyOfModifiers(Method method, Collection<ModifierType> modifiers)
Method has any of the specified modifiers.public static boolean hasAllOfModifiers(Method method, ModifierType... modifiers)
Method has all of the specified modifiers.public static boolean hasAllOfModifiers(Method method, Collection<ModifierType> modifiers)
Method has all of the specified modifiers.public static boolean hasNoneOfModifiers(Method method, ModifierType... modifiers)
Method has none of the specified modifiers.public static boolean hasNoneOfModifiers(Method method, Collection<ModifierType> modifiers)
Method has none of the specified modifiers.public static boolean hasAnyOfModifiers(Field field, ModifierType... modifiers)
Field has any of the specified modifiers.public static boolean hasAnyOfModifiers(Field field, Collection<ModifierType> modifiers)
Field has any of the specified modifiers.public static boolean hasAllOfModifiers(Field field, ModifierType... modifiers)
Field has all of the specified modifiers.public static boolean hasAllOfModifiers(Field field, Collection<ModifierType> modifiers)
Field has all of the specified modifiers.public static boolean hasNoneOfModifiers(Field field, ModifierType... modifiers)
Field has none of the specified modifiers.public static boolean hasNoneOfModifiers(Field field, Collection<ModifierType> modifiers)
Field has none of the specified modifiers.@Nullable public static Field getFieldSafely(@NotNull Class classType, @NotNull String fieldName)
classType - type of the class where field can be locatedfieldName - field name@NotNull public static Field getField(@NotNull Class<?> classType, @NotNull String fieldName) throws NoSuchFieldException
protected, private and package local fields.classType - type of the class where field can be locatedfieldName - field nameNoSuchFieldException - if field was not foundpublic static Class<?> getFieldTypeSafely(Class classType, String fieldName)
classType - type of the class where field can be locatedfieldName - field namepublic static Class<?> getFieldType(Class classType, String fieldName) throws NoSuchFieldException
classType - type of the class where field can be locatedfieldName - field nameNoSuchFieldException - if field was not foundpublic static boolean setFieldValueSafely(Object object, String field, Object value)
object - object instancefield - object fieldvalue - field valuetrue if value was applied successfully, false otherwisepublic static void setFieldValue(Object object, String fieldName, Object value) throws NoSuchFieldException, IllegalAccessException
object - object instancefieldName - object field namevalue - field valueNoSuchFieldException - if field was not foundIllegalAccessException - if field is inaccessiblepublic static boolean setStaticFieldValueSafely(Class classType, String field, Object value)
classType - type of the class where static field can be locatedfield - object fieldvalue - field valuetrue if value was applied successfully, false otherwisepublic static void setStaticFieldValue(Class classType, String fieldName, Object value) throws NoSuchFieldException, IllegalAccessException
classType - type of the class where static field can be locatedfieldName - object field namevalue - field valueNoSuchFieldException - if field was not foundIllegalAccessException - if field is inaccessiblepublic static boolean setFieldValueSafely(Object object, Field field, Object value)
object - object instancefield - object fieldvalue - field valuetrue if value was applied successfully, false otherwisepublic static void setFieldValue(Object object, Field field, Object value) throws IllegalAccessException
object - object instancefield - object fieldvalue - field valueIllegalAccessException - if field is inaccessiblepublic static <T> T getFieldValueSafely(Object object, String fieldName)
T - field value typeobject - object instancefieldName - object field namepublic static <T> T getFieldValue(Object object, String fieldName) throws NoSuchFieldException, IllegalAccessException
T - field value typeobject - object instancefieldName - object field nameNoSuchFieldException - if field was not foundIllegalAccessException - if field is inaccessiblepublic static <T> T getStaticFieldValueSafely(Class classType, String fieldName)
T - returned value typeclassType - class typefieldName - class field namepublic static <T> T getStaticFieldValue(Class classType, String fieldName) throws NoSuchFieldException, IllegalAccessException
T - returned value typeclassType - class typefieldName - class field nameNoSuchFieldException - if field was not foundIllegalAccessException - if field is inaccessible@NotNull public static String getJavaClassName(@NotNull Object classObject)
classObject - object of class type@NotNull public static String getJavaClassName(@NotNull Class classType)
classType - class type@NotNull public static String getClassFileName(@NotNull Object classObject)
classObject - object of class type@NotNull public static String getClassFileName(@NotNull Class classType)
classType - class type@NotNull public static String getClassName(@NotNull Object classObject)
classObject - object of class type@NotNull public static String getClassName(@NotNull Class classType)
classType - class type@NotNull public static String getCompleteClassName(@NotNull Object classObject)
classObject - object of class type@NotNull public static String getCompleteClassName(@NotNull Class classType)
classType - class typepublic static String[] getClassPackages(Object classObject)
classObject - object of class typepublic static String[] getClassPackages(Class classType)
classType - class typepublic static String[] getPackages(String packageName)
packageName - package namepublic static <T> T createInstanceSafely(String canonicalClassName, Object... arguments)
T - class instance typecanonicalClassName - canonical class namearguments - class constructor argumentspublic static <T> T createInstance(String canonicalClassName, Object... arguments) throws ClassNotFoundException, InvocationTargetException, IllegalAccessException, InstantiationException, NoSuchMethodException
T - class instance typecanonicalClassName - canonical class namearguments - class constructor argumentsClassNotFoundException - if class was not foundInvocationTargetException - if method throws an exceptionIllegalAccessException - if method is inaccessibleInstantiationException - if the class is abstractNoSuchMethodException - if method was not foundpublic static <T> T createInstanceSafely(Class theClass, Object... arguments)
T - class instance typetheClass - class to processarguments - class constructor argumentspublic static <T> T createInstance(Class theClass, Object... arguments) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException
T - class instance typetheClass - class to processarguments - class constructor argumentsInstantiationException - if the class is abstractNoSuchMethodException - if method was not foundInvocationTargetException - if method throws an exceptionIllegalAccessException - if method is inaccessiblepublic static Constructor getConstructor(Class theClass, Class... parameterTypes) throws NoSuchMethodException
protected, private and package local constructors.
todo 1. Constructors priority check (by super types)
todo Right now some constructor with [Object] arg might be used instead of constructor with [String]
todo To avoid issues don't call constructors with same amount of arguments and which are cast-able to each other
todo 2. Vararg constructors might not be found in many cases
todo Additional checks/workarounds for such constructors should be added to avoid issuestheClass - class to processparameterTypes - constructor argument typesNoSuchMethodException - if constructor was not foundpublic static <T> T callStaticMethodSafely(String canonicalClassName, String methodName, Object... arguments)
T - method result typecanonicalClassName - canonical class namemethodName - static method namearguments - method argumentspublic static <T> T callStaticMethod(String canonicalClassName, String methodName, Object... arguments) throws ClassNotFoundException, InvocationTargetException, NoSuchMethodException, IllegalAccessException
T - method result typecanonicalClassName - canonical class namemethodName - static method namearguments - method argumentsClassNotFoundException - if class was not foundNoSuchMethodException - if method was not foundInvocationTargetException - if method throws an exceptionIllegalAccessException - if method is inaccessiblepublic static <T> T callStaticMethodSafely(Class theClass, String methodName, Object... arguments)
T - method result typetheClass - class to processmethodName - static method namearguments - method argumentspublic static <T> T callStaticMethod(Class theClass, String methodName, Object... arguments) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException
T - method result typetheClass - class to processmethodName - static method namearguments - static method argumentsNoSuchMethodException - if method was not foundInvocationTargetException - if method throws an exceptionIllegalAccessException - if method is inaccessible@NotNull public static <T> List<T> callMethodsSafely(@NotNull List<?> objects, @NotNull String methodName, @NotNull Object... arguments)
T - method result typeobjects - objects to call methods onmethodName - method namearguments - method arguments@NotNull public static <T> List<T> callMethods(@NotNull List<?> objects, @NotNull String methodName, @NotNull Object... arguments) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException
T - method result typeobjects - objects to call methods onmethodName - method namearguments - method argumentsNoSuchMethodException - if method was not foundInvocationTargetException - if method throws an exceptionIllegalAccessException - if method is inaccessible@NotNull public static Object[] callMethodsSafely(@NotNull Object[] objects, @NotNull String methodName, @NotNull Object... arguments)
objects - objects to call methods onmethodName - method namearguments - method arguments@NotNull public static Object[] callMethods(@NotNull Object[] objects, @NotNull String methodName, @NotNull Object... arguments) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException
objects - objects to call methods onmethodName - method namearguments - method argumentsNoSuchMethodException - if method was not foundInvocationTargetException - if method throws an exceptionIllegalAccessException - if method is inaccessible@Nullable public static <T> T callMethodSafely(@NotNull Object object, @NotNull String methodName, @NotNull Object... arguments)
T - method result typeobject - object instancemethodName - method namearguments - method arguments@Nullable public static <T> T callMethod(@NotNull Object object, @NotNull String methodName, @NotNull Object... arguments) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException
T - method result typeobject - object instancemethodName - method namearguments - method argumentsNoSuchMethodException - if method was not foundInvocationTargetException - if method throws an exceptionIllegalAccessException - if method is inaccessibleExceptionInInitializerError - if the initialization provoked by this method failspublic static Method getFieldGetter(Object object, String field)
object - objectfield - field namepublic static Method getFieldGetter(Class aClass, String field)
aClass - object classfield - field namepublic static String getSetterMethodName(String field)
field - field namepublic static String getGetterMethodName(String field)
field - field namepublic static String getIsGetterMethodName(String field)
field - field namepublic static boolean hasMethod(@NotNull Object object, @NotNull String methodName, @NotNull Object... arguments)
object - objectmethodName - method namearguments - method argumentstrue if method with the specified name and arguments exists in the specified object, false otherwisepublic static boolean hasMethod(@NotNull Class aClass, @NotNull String methodName, @NotNull Object... arguments)
aClass - object classmethodName - method namearguments - method argumentstrue if method with the specified name and arguments exists in the specified class, false otherwisepublic static Method getMethodSafely(Object object, String methodName, Object... arguments)
object - objectmethodName - method namearguments - method argumentspublic static Method getMethodSafely(Class aClass, String methodName, Object... arguments)
aClass - object classmethodName - method namearguments - method argumentspublic static Method getMethod(Object object, String methodName, Object... arguments) throws NoSuchMethodException
object - objectmethodName - method namearguments - method argumentsNoSuchMethodException - if method was not foundpublic static Method getMethod(@NotNull Class aClass, @NotNull String methodName, @NotNull Object... arguments) throws NoSuchMethodException
protected, private and package local methods.
todo 1. Methods priority check (by super types)
todo Right now some method with [Object] arg might be used instead of method with [String]
todo To avoid issues don't call methods with same amount of arguments and which are cast-able to each other
todo 2. Vararg methods might not be found in many cases
todo Additional checks/workarounds for such methods should be added to avoid issuesaClass - object classmethodName - method namearguments - method argumentsNoSuchMethodException - if method was not foundpublic static <T extends Cloneable> T clone(T object) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
T - cloned object typeobject - object to cloneNoSuchMethodException - if method was not foundInvocationTargetException - if method throws an exceptionIllegalAccessException - if method is inaccessiblepublic static <T extends Cloneable> T cloneSafely(T object)
T - cloned object typeobject - object to clonepublic static Class loadClass(String canonicalClassName) throws ClassNotFoundException
canonicalClassName - canonical class nameClassNotFoundException - if class was not foundpublic static Class[] getClassTypes(@NotNull Object[] arguments)
arguments - arguments to processpublic static boolean isAssignable(Class type, Class from)
type - checked whether is assignable, always not nullfrom - checked type, might be nulltrue if first type is assignable from second one, false otherwisepublic static boolean isPrimitive(Object object)
object must never be null.object - object to checktrue if specified object has primitive type, false otherwisepublic static boolean isPrimitive(Class<?> type)
clazz must never be null.type - class type to checktrue if specified class type is primitive, false otherwisepublic static Object getDefaultPrimitiveValue(Class<?> type)
type - primitive class typepublic static boolean containsInClassOrSuperclassName(Class theClass, String text)
theClass - class to processtext - text to search fortrue if one of superclasses contains specified text in its name, false otherwisepublic static Class getClosestSuperclass(Object object1, Object object2)
Copyright © 2020. All rights reserved.