|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.picocontainer.parameters.CollectionComponentParameter
public class CollectionComponentParameter
A CollectionComponentParameter should be used to support inject an Array, a
Collectionor Mapof components automatically. The collection will contain
all components of a special type and additionally the type of the key may be specified. In
case of a map, the map's keys are the one of the component adapter.
| Field Summary | |
|---|---|
static CollectionComponentParameter |
ARRAY
Use ARRAY as Parameterfor an Array that must have elements. |
static CollectionComponentParameter |
ARRAY_ALLOW_EMPTY
Use ARRAY_ALLOW_EMPTY as Parameterfor an Array that may have no
elements. |
| Fields inherited from interface org.picocontainer.Parameter |
|---|
DEFAULT, ZERO |
| Constructor Summary | |
|---|---|
CollectionComponentParameter()
Expect an Arrayof an appropriate type as parameter. |
|
CollectionComponentParameter(boolean emptyCollection)
Expect an Arrayof an appropriate type as parameter. |
|
CollectionComponentParameter(Class componentValueType,
boolean emptyCollection)
Expect any of the collection types Array,Collectionor Mapas
parameter. |
|
CollectionComponentParameter(Class componentKeyType,
Class componentValueType,
boolean emptyCollection)
Expect any of the collection types Array,Collectionor Mapas
parameter. |
|
| Method Summary | |
|---|---|
void |
accept(PicoVisitor visitor)
Visit the current Parameter. |
protected boolean |
evaluate(ComponentAdapter adapter)
Evaluate whether the given component adapter will be part of the collective type. |
protected Map<Object,ComponentAdapter<?>> |
getMatchingComponentAdapters(PicoContainer container,
ComponentAdapter adapter,
Class keyType,
Class valueType)
Collect the matching ComponentAdapter instances. |
boolean |
isResolvable(PicoContainer container,
ComponentAdapter adapter,
Class expectedType,
ParameterName expectedParameterName)
Check for a successful dependency resolution of the parameter for the expected type. |
Object |
resolveInstance(PicoContainer container,
ComponentAdapter adapter,
Class expectedType,
ParameterName expectedParameterName)
Resolve the parameter for the expected type. |
void |
verify(PicoContainer container,
ComponentAdapter adapter,
Class expectedType,
ParameterName expectedParameterName)
Verify a successful dependency resolution of the parameter for the expected type. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final CollectionComponentParameter ARRAY
ARRAY as Parameterfor an Array that must have elements.
public static final CollectionComponentParameter ARRAY_ALLOW_EMPTY
ARRAY_ALLOW_EMPTY as Parameterfor an Array that may have no
elements.
| Constructor Detail |
|---|
public CollectionComponentParameter()
Arrayof an appropriate type as parameter. At least one component of
the array's component type must exist.
public CollectionComponentParameter(boolean emptyCollection)
Arrayof an appropriate type as parameter.
emptyCollection - true if an empty array also is a valid dependency
resolution.
public CollectionComponentParameter(Class componentValueType,
boolean emptyCollection)
Array,Collectionor Mapas
parameter.
componentValueType - the type of the components (ignored in case of an Array)emptyCollection - true if an empty collection resolves the
dependency.
public CollectionComponentParameter(Class componentKeyType,
Class componentValueType,
boolean emptyCollection)
Array,Collectionor Mapas
parameter.
componentKeyType - the type of the component's keycomponentValueType - the type of the components (ignored in case of an Array)emptyCollection - true if an empty collection resolves the
dependency.| Method Detail |
|---|
public Object resolveInstance(PicoContainer container,
ComponentAdapter adapter,
Class expectedType,
ParameterName expectedParameterName)
null
If the expected type is not one of the collection types Array,
Collectionor Map. An empty collection is only a valid resolution, if
the emptyCollection flag was set.
resolveInstance in interface Parametercontainer - the container from which dependencies are resolved.adapter - the ComponentAdapter that is asking for the instanceexpectedType - the type that the returned instance needs to match.expectedParameterName - Expected parameter name
null
PicoCompositionException - if a referenced component could not be instantiated.
public boolean isResolvable(PicoContainer container,
ComponentAdapter adapter,
Class expectedType,
ParameterName expectedParameterName)
Array,Collectionor Map. An empty collection is only a valid
resolution, if the emptyCollection flag was set.
isResolvable in interface Parametercontainer - the container from which dependencies are resolved.adapter - the ComponentAdapter that is asking for the instanceexpectedType - the required typeexpectedParameterName - Expected parameter name
true if matching components were found or an empty collective type
is allowed
public void verify(PicoContainer container,
ComponentAdapter adapter,
Class expectedType,
ParameterName expectedParameterName)
Array,
Collectionor Map. An empty collection is only a valid resolution, if
the emptyCollection flag was set.
verify in interface Parametercontainer - the container from which dependencies are resolved.adapter - the ComponentAdapter that is asking for the verificationexpectedType - the required typeexpectedParameterName - Expected parameter name
PicoCompositionException - if parameter and its dependencies cannot be resolvedpublic void accept(PicoVisitor visitor)
Parameter.
accept in interface Parametervisitor - the visitor.Parameter.accept(org.picocontainer.PicoVisitor)protected boolean evaluate(ComponentAdapter adapter)
adapter - a ComponentAdapter value
true if the adapter takes part
protected Map<Object,ComponentAdapter<?>> getMatchingComponentAdapters(PicoContainer container,
ComponentAdapter adapter,
Class keyType,
Class valueType)
container - container to use for dependency resolutionadapter - ComponentAdapter to excludekeyType - the compatible type of the keyvalueType - the compatible type of the addComponent
Map with the ComponentAdapter instances and their component keys as map key.
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||