public class ReflectHelpers
extends java.lang.Object
Classes and Methods.| Modifier and Type | Class and Description |
|---|---|
static class |
ReflectHelpers.ObjectsClassComparator
A
Comparator that uses the object's class' canonical name to compare them. |
| Constructor and Description |
|---|
ReflectHelpers() |
| Modifier and Type | Method and Description |
|---|---|
static java.util.Collection<java.lang.reflect.Field> |
declaredFieldsWithAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> anno,
java.lang.Class<?> startClass,
java.lang.Class<?> stopClass) |
static java.util.Collection<java.lang.reflect.Method> |
declaredMethodsWithAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> anno,
java.lang.Class<?> startClass,
java.lang.Class<?> stopClass) |
static java.lang.ClassLoader |
findClassLoader()
Finds the appropriate
ClassLoader to be used by the ServiceLoader.load(java.lang.Class<S>, java.lang.ClassLoader) call,
which by default would use the context ClassLoader, which can be null. |
static java.lang.ClassLoader |
findClassLoader(java.lang.Class<?>... classes)
Find the common classloader of all these classes.
|
static java.lang.ClassLoader |
findClassLoader(java.lang.ClassLoader proposed)
Finds the appropriate
ClassLoader to be used by the ServiceLoader.load(java.lang.Class<S>, java.lang.ClassLoader) call,
which by default would use the proposed ClassLoader, which can be null. |
static java.lang.String |
formatAnnotation(java.lang.annotation.Annotation annotation)
A
Function that returns a concise string for a Annotation. |
static java.lang.String |
formatMethod(java.lang.reflect.Method input)
Returns a string representation of the signature of a
Method. |
static java.lang.String |
formatMethodWithClass(java.lang.reflect.Method input)
Returns a string representation of the class + method signature for a
Method. |
static java.lang.Iterable<java.lang.reflect.Method> |
getClosureOfMethodsOnInterface(java.lang.Class<?> iface)
Returns all the methods visible from
iface. |
static java.lang.Iterable<java.lang.reflect.Method> |
getClosureOfMethodsOnInterfaces(java.lang.Iterable<? extends java.lang.Class<?>> interfaces)
Returns all the methods visible from the provided interfaces.
|
static <T> java.lang.Iterable<T> |
loadServicesOrdered(java.lang.Class<T> iface)
A version of
loadServicesOrdered that uses a default class loader. |
static <T> java.lang.Iterable<T> |
loadServicesOrdered(java.lang.Class<T> iface,
java.lang.ClassLoader classLoader)
Returns instances of all implementations of the the specified
iface. |
static java.lang.String |
simpleTypeDescription(java.lang.reflect.Type input)
A
Function that formats types. |
public static java.lang.String formatMethod(java.lang.reflect.Method input)
Method.public static java.lang.String formatMethodWithClass(java.lang.reflect.Method input)
Method.public static java.lang.String formatAnnotation(java.lang.annotation.Annotation annotation)
Function that returns a concise string for a Annotation.public static java.lang.String simpleTypeDescription(java.lang.reflect.Type input)
Function that formats types.public static java.lang.Iterable<java.lang.reflect.Method> getClosureOfMethodsOnInterfaces(java.lang.Iterable<? extends java.lang.Class<?>> interfaces)
interfaces - The interfaces to use when searching for all their methods.Methods which interfaces expose.public static java.lang.Iterable<java.lang.reflect.Method> getClosureOfMethodsOnInterface(java.lang.Class<?> iface)
iface.iface - The interface to use when searching for all its methods.Methods which iface exposes.public static <T> java.lang.Iterable<T> loadServicesOrdered(java.lang.Class<T> iface,
java.lang.ClassLoader classLoader)
iface. Instances are
sorted by their class' name to ensure deterministic execution.T - The type of ifaceiface - The interface to load implementations ofclassLoader - The class loader to usepublic static <T> java.lang.Iterable<T> loadServicesOrdered(java.lang.Class<T> iface)
loadServicesOrdered that uses a default class loader.T - The type of ifaceiface - The interface to load implementations ofpublic static java.lang.ClassLoader findClassLoader(java.lang.ClassLoader proposed)
ClassLoader to be used by the ServiceLoader.load(java.lang.Class<S>, java.lang.ClassLoader) call,
which by default would use the proposed ClassLoader, which can be null. The fallback is
as follows: context ClassLoader, class ClassLoader and finaly the system ClassLoader.public static java.lang.ClassLoader findClassLoader(java.lang.Class<?>... classes)
public static java.lang.ClassLoader findClassLoader()
ClassLoader to be used by the ServiceLoader.load(java.lang.Class<S>, java.lang.ClassLoader) call,
which by default would use the context ClassLoader, which can be null. The fallback is
as follows: context ClassLoader, class ClassLoader and finally the system ClassLoader.public static java.util.Collection<java.lang.reflect.Method> declaredMethodsWithAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> anno,
java.lang.Class<?> startClass,
java.lang.Class<?> stopClass)
public static java.util.Collection<java.lang.reflect.Field> declaredFieldsWithAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> anno,
java.lang.Class<?> startClass,
java.lang.Class<?> stopClass)