@Beta @PublicAPI public final class Discovery extends java.lang.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 java.lang.annotation.Annotation> |
getAnnotation(java.lang.Class<T> a,
java.lang.Object o)
Retrieve an annotation on an object.
|
static <T extends java.lang.annotation.Annotation> |
getAnnotationForClass(java.lang.Class<T> annotationClass,
java.lang.Class<?> clazz)
Retrieve annotation for a class.
|
static <T extends java.lang.annotation.Annotation> |
getAnnotationIfPresent(java.lang.Class<T> a,
java.lang.Object o)
Retrieve an annotation on an object if present.
|
static Description |
getDescriptionAnnotation(java.lang.Object o)
Retrieve the description annotation on an object.
|
static <T> com.google.common.base.Optional<ParameterBuilder<T>> |
initializeBuilderIfExists(T o)
Create initial Builder if possible.
|
static boolean |
isParametrized(java.lang.Object o)
Check if an object is parametrized.
|
static <T> java.util.List<CreatorWrapper<T>> |
listCreators(java.lang.Object o,
java.lang.Class<T> targetType)
CreatorWrapper acts as a type-dependent service loader.
|
static <T> java.util.List<InstanceWrapper<T>> |
listInstances(java.lang.Class<T> type)
Collect instances of a specific type.
|
static java.util.List<ParameterWrapper> |
listParameters(java.lang.Object o)
Retrieve parameters for a mutable parameter object.
|
static <T> com.google.common.base.Optional<InstanceWrapper<T>> |
selectInstance(java.lang.Class<T> type,
java.lang.String shortName)
Look up an instance by its short name.
|
@Beta public static <T> java.util.List<InstanceWrapper<T>> listInstances(java.lang.Class<T> type)
T
- Type to collecttype
- Type to collectpublic static <T> com.google.common.base.Optional<InstanceWrapper<T>> selectInstance(java.lang.Class<T> type, java.lang.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(java.lang.Object o)
o
- Object in question@Beta public static java.util.List<ParameterWrapper> listParameters(java.lang.Object o)
Parametrized.parameterSetMode()
on the objects Parametrized
annotation.o
- Mutable parametrized object annotated with Parametrized
java.lang.IllegalArgumentException
- when o is not annotated with Parametrized
or no parameters found@Beta public static <T extends java.lang.annotation.Annotation> T getAnnotationForClass(java.lang.Class<T> annotationClass, java.lang.Class<?> clazz)
T
- Annotation classannotationClass
- Annotation classclazz
- Target classjava.lang.IllegalArgumentException
- when no Description
annotation found@Beta public static <T extends java.lang.annotation.Annotation> com.google.common.base.Optional<T> getAnnotationIfPresent(java.lang.Class<T> a, java.lang.Object o)
T
- Annotation classa
- Annotation classo
- Object to examine@Beta public static <T extends java.lang.annotation.Annotation> T getAnnotation(java.lang.Class<T> a, java.lang.Object o)
T
- Annotation classa
- Annotation classo
- Object to examinejava.lang.IllegalArgumentException
- when no annotation found@Beta public static Description getDescriptionAnnotation(java.lang.Object o)
o
- Object to examinejava.lang.IllegalArgumentException
- when no Description
annotation found@Beta public static <T> java.util.List<CreatorWrapper<T>> listCreators(java.lang.Object o, java.lang.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> com.google.common.base.Optional<ParameterBuilder<T>> initializeBuilderIfExists(T o)
Builder association is identified by annotation BuilderClass
T
- Parameter object typeo
- An object