public interface GlobalContext
Injector
.
This is the central repository containing all parts managed by the injector. Parts stored inhere can be either
accessed via the getPart or findPart methods. Also all annotations processed by an appropriate
FieldAnnotationProcessor
(like Part
) will use this context to find the
requested part.
Modifier and Type | Method and Description |
---|---|
<P> P |
findPart(String uniqueName,
Class<P> clazz)
Like
getPart(String, Class) this method tried to find the part with the given name, registered for the
given lookup class. |
<P> Collection<Tuple<String,P>> |
getNamedParts(Class<P> partInterface)
Returns all parts which are currently registered for the given lookup class and have a name attached.
|
<P> P |
getPart(Class<P> clazz)
Finds the previously registered part for the given lookup class.
|
<P> P |
getPart(String uniqueName,
Class<P> clazz)
Retrieves a part of the requested type with the given unique name.
|
<P> PartCollection<P> |
getPartCollection(Class<P> partInterface)
Returns a
PartCollection which contains all parts registered for the given lookup class. |
<P> Collection<P> |
getParts(Class<? extends P> partInterface)
Returns all parts which are currently registered for the given lookup class.
|
<L,P> Collection<P> |
getParts(Class<L> lookupClass,
Class<? extends P> partType)
Returns all parts which are currently registered for the given lookup class.
|
void |
registerDynamicPart(String uniqueName,
Object part,
Class<?> partInterface)
Registers a new part for the given name and lookup classes.
|
<T> T |
wire(T object)
Processes all annotations of the given objects class (or super classes).
|
@Nullable <P> P getPart(@Nonnull Class<P> clazz)
If several parts where registered for this class, the first one is chosen. If no part was registered, null is returned.
P
- the type of the requested partclazz
- the class used to lookup the requested part@Nullable <P> P getPart(@Nonnull String uniqueName, @Nonnull Class<P> clazz)
If no matching part is found, null is returned.
P
- the type of the requested partuniqueName
- the name for which the part was registeredclazz
- one of the lookup classes for which the part was registered@Nonnull <P> P findPart(@Nonnull String uniqueName, @Nonnull Class<P> clazz)
getPart(String, Class)
this method tried to find the part with the given name, registered for the
given lookup class. Rather than returning null when no part is found, this throws a
HandledException
with an appropriate message.P
- the type of the requested partuniqueName
- the name for which the part was registeredclazz
- one of the lookup classes for which the part was registeredHandledException
- if no matching part was found@Nonnull <L,P> Collection<P> getParts(@Nonnull Class<L> lookupClass, @Nonnull Class<? extends P> partType)
L
- the type of the lookup classP
- the type of the requested partslookupClass
- one of the lookup classes for which the parts of interest were registeredpartType
- the expected type of the parts returned@Nonnull <P> Collection<P> getParts(@Nonnull Class<? extends P> partInterface)
P
- the type of the requested partspartInterface
- one of the lookup classes for which the parts of interest were registered@Nonnull <P> Collection<Tuple<String,P>> getNamedParts(@Nonnull Class<P> partInterface)
P
- the type of the requested partspartInterface
- one of the lookup classes for which the parts of interest were registered@Nonnull <P> PartCollection<P> getPartCollection(@Nonnull Class<P> partInterface)
PartCollection
which contains all parts registered for the given lookup class.P
- the type of the requested partspartInterface
- one of the lookup classes for which the parts of interest were registered@Nonnull <T> T wire(@Nonnull T object)
T
- the type of the object to permit a qualified return typeobject
- the object which annotations should be processed to fill the respective fieldsvoid registerDynamicPart(@Nonnull String uniqueName, @Nonnull Object part, @Nonnull Class<?> partInterface)
In contrast to MutableGlobalContext.registerPart(String, Object, Class[])
this
method may replace already existing implementations.
uniqueName
- the unique name of the partpart
- the part itselfpartInterface
- the lookup class for which the part is registeredCopyright © 2018. All rights reserved.