Modifier and Type | Method and Description |
---|---|
static void |
cacheAnnotatedObjects(Class<?> scannedClass,
Query query)
This method scans the provided class, its superclasses and interfaces for
all supported
Annotation : AnnotatedElement pairs. |
static boolean |
canCast(Class<?> c,
Class<?> type)
Deprecated.
|
static boolean |
canCast(Object obj,
Class<?> type)
Deprecated.
|
static boolean |
canConvert(Class<?> c,
Class<?> type)
Deprecated.
|
static boolean |
canConvert(Object value,
Class<?> type)
Deprecated.
|
static <T> T |
cast(Object obj,
Class<T> type)
Deprecated.
|
static int |
compare(Class<?> c1,
Class<?> c2)
Compares two
Class objects using their fully qualified names. |
static <T> T |
convert(Object value,
Class<T> type)
Deprecated.
|
static <A extends Annotation> |
getAnnotatedFields(Class<?> c,
Class<A> annotationClass)
Gets the given class's
Field s marked with the annotation of the
specified class. |
static <A extends Annotation> |
getAnnotatedFields(Class<?> c,
Class<A> annotationClass,
List<Field> fields)
Gets the given class's
Field s marked with the annotation of the
specified class. |
static <A extends Annotation> |
getAnnotatedMethods(Class<?> c,
Class<A> annotationClass)
Gets the given class's
Method s marked with the annotation of the
specified class. |
static <A extends Annotation> |
getAnnotatedMethods(Class<?> c,
Class<A> annotationClass,
List<Method> methods)
Gets the given class's
Method s marked with the annotation of the
specified class. |
static Class<?> |
getArrayClass(Class<?> elementClass)
Deprecated.
Use
Types.array(Class) instead. |
static Field |
getField(Class<?> c,
String fieldName)
Deprecated.
Use
Types.field(java.lang.Class<?>, java.lang.String) instead. |
static Field |
getField(String className,
String fieldName)
Deprecated.
Use
Types.field(java.lang.Class<?>, java.lang.String) instead. |
static Type |
getGenericType(Field field,
Class<?> type)
Deprecated.
Use
Types.fieldType(Field, Class) instead. |
static URL |
getLocation(Class<?> c)
Deprecated.
Use
Types.location(java.lang.Class<?>) and Types.load(java.lang.String) instead. |
static URL |
getLocation(String className)
Deprecated.
Use
Types.location(java.lang.Class<?>) and Types.load(java.lang.String) instead. |
static URL |
getLocation(String className,
ClassLoader classLoader)
Deprecated.
Use
Types.location(java.lang.Class<?>) and Types.load(java.lang.String) instead. |
static <T> Class<T> |
getNonprimitiveType(Class<T> type)
Deprecated.
use
Types.box(Class) |
static <T> T |
getNullValue(Class<T> type)
Deprecated.
|
static List<Class<?>> |
getTypes(Field field,
Class<?> type)
Deprecated.
Use
Types.fieldType(Field, Class) and Types.raws(java.lang.reflect.Type)
instead. |
static Object |
getValue(Field field,
Object instance)
Gets the given field's value of the specified object instance, or null if
the value cannot be obtained.
|
static boolean |
hasClass(String className)
Deprecated.
Use
Types.load(String) instead. |
static boolean |
hasClass(String className,
ClassLoader classLoader)
Deprecated.
Use
Types.load(String, ClassLoader) instead. |
static boolean |
isBoolean(Class<?> type)
Deprecated.
Use
Types.isBoolean(java.lang.Class<?>) instead. |
static boolean |
isByte(Class<?> type)
Deprecated.
Use
Types.isByte(java.lang.Class<?>) instead. |
static boolean |
isCharacter(Class<?> type)
Deprecated.
Use
Types.isCharacter(java.lang.Class<?>) instead. |
static boolean |
isDouble(Class<?> type)
Deprecated.
Use
Types.isDouble(java.lang.Class<?>) instead. |
static boolean |
isFloat(Class<?> type)
Deprecated.
Use
Types.isFloat(java.lang.Class<?>) instead. |
static boolean |
isInteger(Class<?> type)
Deprecated.
Use
Types.isInteger(java.lang.Class<?>) instead. |
static boolean |
isLong(Class<?> type)
Deprecated.
Use
Types.isLong(java.lang.Class<?>) instead. |
static boolean |
isNumber(Class<?> type)
Deprecated.
Use
Types.isNumber(java.lang.Class<?>) instead. |
static boolean |
isShort(Class<?> type)
Deprecated.
Use
Types.isShort(java.lang.Class<?>) instead. |
static boolean |
isText(Class<?> type)
Deprecated.
Use
Types.isText(java.lang.Class<?>) instead. |
static Class<?> |
loadClass(String name)
Deprecated.
Use
Types.load(String) instead. |
static Class<?> |
loadClass(String className,
boolean quietly)
Deprecated.
Use
Types.load(String, boolean) instead. |
static Class<?> |
loadClass(String name,
ClassLoader classLoader)
Deprecated.
Use
Types.load(String, ClassLoader) instead. |
static Class<?> |
loadClass(String name,
ClassLoader classLoader,
boolean quietly)
Deprecated.
Use
Types.load(String, ClassLoader, boolean) instead. |
static void |
setValue(Field field,
Object instance,
Object value)
Sets the given field's value of the specified object instance.
|
public static <A extends Annotation> List<Method> getAnnotatedMethods(Class<?> c, Class<A> annotationClass)
Method
s marked with the annotation of the
specified class.
Unlike Class.getMethods()
, the result will include any non-public
methods, including methods defined in supertypes of the given class.
c
- The class to scan for annotated methods.annotationClass
- The type of annotation for which to scan.public static <A extends Annotation> void getAnnotatedMethods(Class<?> c, Class<A> annotationClass, List<Method> methods)
Method
s marked with the annotation of the
specified class.
Unlike Class.getMethods()
, the result will include any non-public
methods, including methods defined in supertypes of the given class.
c
- The class to scan for annotated methods.annotationClass
- The type of annotation for which to scan.methods
- The list to which matching methods will be added.public static <A extends Annotation> List<Field> getAnnotatedFields(Class<?> c, Class<A> annotationClass)
Field
s marked with the annotation of the
specified class.
Unlike Class.getFields()
, the result will include any non-public
fields, including fields defined in supertypes of the given class.
c
- The class to scan for annotated fields.annotationClass
- The type of annotation for which to scan.public static <A extends Annotation> void getAnnotatedFields(Class<?> c, Class<A> annotationClass, List<Field> fields)
Field
s marked with the annotation of the
specified class.
Unlike Class.getFields()
, the result will include any non-public
fields, including fields defined in supertypes of the given class.
c
- The class to scan for annotated fields.annotationClass
- The type of annotation for which to scan.fields
- The list to which matching fields will be added.public static void cacheAnnotatedObjects(Class<?> scannedClass, Query query)
Annotation
: AnnotatedElement
pairs.
These are then cached to remove the need for future queries.
By combining multiple Annotation : AnnotatedElement
pairs in one
query, we can limit the number of times a class's superclass and interface
hierarchy are traversed.
scannedClass
- Class to scanquery
- Pairs of Annotation
and AnnotatedElement
s to
discover.public static Object getValue(Field field, Object instance)
public static void setValue(Field field, Object instance, Object value)
IllegalArgumentException
- if the value cannot be set.public static int compare(Class<?> c1, Class<?> c2)
Class
objects using their fully qualified names.
Note: this method provides a natural ordering that may be inconsistent with
equals. Specifically, two unequal classes may return 0 when compared in
this fashion if they represent the same class loaded using two different
ClassLoader
s. Hence, if this method is used as a basis for
implementing Comparable.compareTo(T)
or
Comparator.compare(T, T)
, that implementation may want to
impose logic beyond that of this method, for breaking ties, if a total
ordering consistent with equals is always required.
@Deprecated public static Class<?> loadClass(String name)
Types.load(String)
instead.@Deprecated public static Class<?> loadClass(String name, ClassLoader classLoader)
Types.load(String, ClassLoader)
instead.@Deprecated public static Class<?> loadClass(String className, boolean quietly)
Types.load(String, boolean)
instead.@Deprecated public static Class<?> loadClass(String name, ClassLoader classLoader, boolean quietly)
Types.load(String, ClassLoader, boolean)
instead.@Deprecated public static boolean hasClass(String className)
Types.load(String)
instead.@Deprecated public static boolean hasClass(String className, ClassLoader classLoader)
Types.load(String, ClassLoader)
instead.@Deprecated public static URL getLocation(String className)
Types.location(java.lang.Class<?>)
and Types.load(java.lang.String)
instead.@Deprecated public static URL getLocation(String className, ClassLoader classLoader)
Types.location(java.lang.Class<?>)
and Types.load(java.lang.String)
instead.@Deprecated public static URL getLocation(Class<?> c)
Types.location(java.lang.Class<?>)
and Types.load(java.lang.String)
instead.@Deprecated public static boolean isBoolean(Class<?> type)
Types.isBoolean(java.lang.Class<?>)
instead.@Deprecated public static boolean isByte(Class<?> type)
Types.isByte(java.lang.Class<?>)
instead.@Deprecated public static boolean isCharacter(Class<?> type)
Types.isCharacter(java.lang.Class<?>)
instead.@Deprecated public static boolean isDouble(Class<?> type)
Types.isDouble(java.lang.Class<?>)
instead.@Deprecated public static boolean isFloat(Class<?> type)
Types.isFloat(java.lang.Class<?>)
instead.@Deprecated public static boolean isInteger(Class<?> type)
Types.isInteger(java.lang.Class<?>)
instead.@Deprecated public static boolean isLong(Class<?> type)
Types.isLong(java.lang.Class<?>)
instead.@Deprecated public static boolean isShort(Class<?> type)
Types.isShort(java.lang.Class<?>)
instead.@Deprecated public static boolean isNumber(Class<?> type)
Types.isNumber(java.lang.Class<?>)
instead.@Deprecated public static boolean isText(Class<?> type)
Types.isText(java.lang.Class<?>)
instead.@Deprecated public static <T> T convert(Object value, Class<T> type)
ConversionUtils.convert(Object, Class)
@Deprecated public static boolean canConvert(Class<?> c, Class<?> type)
ConversionUtils.canConvert(Class, Class)
@Deprecated public static boolean canConvert(Object value, Class<?> type)
ConversionUtils.canConvert(Object, Class)
@Deprecated public static <T> T cast(Object obj, Class<T> type)
Types.cast(Object, Class)
@Deprecated public static boolean canCast(Class<?> c, Class<?> type)
Types.isAssignable(Type, Type)
@Deprecated public static boolean canCast(Object obj, Class<?> type)
Types.isInstance(Object, Class)
@Deprecated public static <T> Class<T> getNonprimitiveType(Class<T> type)
Types.box(Class)
@Deprecated public static <T> T getNullValue(Class<T> type)
Types.nullValue(Class)
@Deprecated public static List<Class<?>> getTypes(Field field, Class<?> type)
Types.fieldType(Field, Class)
and Types.raws(java.lang.reflect.Type)
instead.@Deprecated public static Type getGenericType(Field field, Class<?> type)
Types.fieldType(Field, Class)
instead.@Deprecated public static Field getField(String className, String fieldName)
Types.field(java.lang.Class<?>, java.lang.String)
instead.@Deprecated public static Field getField(Class<?> c, String fieldName)
Types.field(java.lang.Class<?>, java.lang.String)
instead.@Deprecated public static Class<?> getArrayClass(Class<?> elementClass)
Types.array(Class)
instead.Copyright © 2015–2022 SciJava. All rights reserved.