@Beta @PublicAPI public final class Discovery extends Object
Please note that this class is marked with Beta
annotation, so it can be subject of incompatible changes
or removal in later releases.
Modifier and Type | Method and Description |
---|---|
static <T extends Annotation> |
getAnnotation(Class<T> a,
Object o)
Retrieve an annotation on an object.
|
static <T extends Annotation> |
getAnnotationForClass(Class<T> annotationClass,
Class<?> clazz)
Retrieve annotation for a class.
|
static <T extends Annotation> |
getAnnotationIfPresent(Class<T> a,
Object o)
Retrieve an annotation on an object if present.
|
static Description |
getDescriptionAnnotation(Object o)
Retrieve the description annotation on an object.
|
static <T> Optional<ParameterBuilder<T>> |
initializeBuilderIfExists(T o)
Create initial Builder if possible.
|
static boolean |
isParametrized(Object o)
Check if an object is parametrized.
|
static <T> List<CreatorWrapper<T>> |
listCreators(Object o,
Class<T> targetType)
CreatorWrapper acts as a type-dependent service loader.
|
static <T> List<InstanceWrapper<T>> |
listInstances(Class<T> type)
Collect instances of a specific type.
|
static List<ParameterWrapper> |
listParameters(Object o)
Retrieve parameters for a mutable parameter object.
|
static <T> Optional<InstanceWrapper<T>> |
selectInstance(Class<T> type,
String shortName)
Look up an instance by its short name.
|
@Beta public static <T> List<InstanceWrapper<T>> listInstances(Class<T> type)
T
- Type to collecttype
- Type to collectpublic static <T> Optional<InstanceWrapper<T>> selectInstance(Class<T> type, String shortName)
T
- Type to collecttype
- Type to collect (by listInstances(java.lang.Class)
shortName
- Short name of the instance to select@Beta public static boolean isParametrized(Object o)
o
- Object in question@Beta public static List<ParameterWrapper> listParameters(Object o)
Parametrized.parameterSetMode()
on the objects Parametrized
annotation.o
- Mutable parametrized object annotated with Parametrized
IllegalArgumentException
- when o is not annotated with Parametrized
or no parameters found@Beta public static <T extends Annotation> T getAnnotationForClass(Class<T> annotationClass, Class<?> clazz)
T
- Annotation classannotationClass
- Annotation classclazz
- Target classIllegalArgumentException
- when no Description
annotation found@Beta public static <T extends Annotation> Optional<T> getAnnotationIfPresent(Class<T> a, Object o)
T
- Annotation classa
- Annotation classo
- Object to examine@Beta public static <T extends Annotation> T getAnnotation(Class<T> a, Object o)
T
- Annotation classa
- Annotation classo
- Object to examineIllegalArgumentException
- when no annotation found@Beta public static Description getDescriptionAnnotation(Object o)
o
- Object to examineIllegalArgumentException
- when no Description
annotation found@Beta public static <T> List<CreatorWrapper<T>> listCreators(Object o, Class<T> targetType)
Note that the order of the returned list is defined by
T
- type to be createdtargetType
- type to be createdo
- Instance on which the creators should be called@Beta public static <T> Optional<ParameterBuilder<T>> initializeBuilderIfExists(T o)
Builder association is identified by annotation BuilderClass
T
- Parameter object typeo
- An object