| java.lang.Object org.picocontainer.parameters.CollectionComponentParameter
All known Subclasses: org.picocontainer.gems.constraints.CollectionConstraint, org.picocontainer.gems.constraints.AbstractConstraint,
CollectionComponentParameter | public class CollectionComponentParameter implements Parameter,Serializable(Code) | | A CollectionComponentParameter should be used to support inject an
Array , a
Collection or
Map of 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.
author: Aslak Hellesøy author: Jörg Schaible |
Method Summary | |
public 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. | public boolean | isResolvable(PicoContainer container, ComponentAdapter adapter, Class expectedType, NameBinding expectedNameBinding, boolean useNames, Annotation binding) Check for a successful dependency resolution of the parameter for the expected type. | public Object | resolveInstance(PicoContainer container, ComponentAdapter adapter, Class expectedType, NameBinding expectedNameBinding, boolean useNames, Annotation binding) Resolve the parameter for the expected type. | public void | verify(PicoContainer container, ComponentAdapter adapter, Class expectedType, NameBinding expectedNameBinding, boolean useNames, Annotation binding) Verify a successful dependency resolution of the parameter for the expected type. |
CollectionComponentParameter | public CollectionComponentParameter()(Code) | | Expect an
Array of an appropriate type as parameter. At least one component of
the array's component type must exist.
|
CollectionComponentParameter | public CollectionComponentParameter(boolean emptyCollection)(Code) | | Expect an
Array of an appropriate type as parameter.
Parameters: emptyCollection - true if an empty array also is a valid dependencyresolution. |
CollectionComponentParameter | public CollectionComponentParameter(Class componentValueType, boolean emptyCollection)(Code) | | Expect any of the collection types
Array ,
Collection or
Map as
parameter.
Parameters: componentValueType - the type of the components (ignored in case of an Array) Parameters: emptyCollection - true if an empty collection resolves thedependency. |
CollectionComponentParameter | public CollectionComponentParameter(Class componentKeyType, Class componentValueType, boolean emptyCollection)(Code) | | Expect any of the collection types
Array ,
Collection or
Map as
parameter.
Parameters: componentKeyType - the type of the component's key Parameters: componentValueType - the type of the components (ignored in case of an Array) Parameters: emptyCollection - true if an empty collection resolves thedependency. |
evaluate | protected boolean evaluate(ComponentAdapter adapter)(Code) | | Evaluate whether the given component adapter will be part of the collective type.
Parameters: adapter - a ComponentAdapter value true if the adapter takes part |
getMatchingComponentAdapters | protected Map<Object, ComponentAdapter<?>> getMatchingComponentAdapters(PicoContainer container, ComponentAdapter adapter, Class keyType, Class valueType)(Code) | | Collect the matching ComponentAdapter instances.
Parameters: container - container to use for dependency resolution Parameters: adapter - ComponentAdapter to exclude Parameters: keyType - the compatible type of the key Parameters: valueType - the compatible type of the addComponent a Map with the ComponentAdapter instances and their component keys as map key. |
isResolvable | public boolean isResolvable(PicoContainer container, ComponentAdapter adapter, Class expectedType, NameBinding expectedNameBinding, boolean useNames, Annotation binding)(Code) | | Check for a successful dependency resolution of the parameter for the expected type. The
dependency can only be satisfied if the expected type is one of the collection types
Array ,
Collection or
Map . An empty collection is only a valid
resolution, if the emptyCollection flag was set.
Parameters: container - Parameters: adapter - Parameters: expectedType - Parameters: expectedNameBinding - Parameters: useNames - Parameters: binding - true if matching components were found or an empty collective typeis allowed |
resolveInstance | public Object resolveInstance(PicoContainer container, ComponentAdapter adapter, Class expectedType, NameBinding expectedNameBinding, boolean useNames, Annotation binding)(Code) | | Resolve the parameter for the expected type. The method will return null
If the expected type is not one of the collection types
Array ,
Collection or
Map . An empty collection is only a valid resolution, if
the emptyCollection flag was set.
Parameters: container - Parameters: adapter - Parameters: expectedType - Parameters: expectedNameBinding - Parameters: useNames - Parameters: binding - the instance of the collection type or null throws: PicoCompositionException - |
verify | public void verify(PicoContainer container, ComponentAdapter adapter, Class expectedType, NameBinding expectedNameBinding, boolean useNames, Annotation binding)(Code) | | Verify a successful dependency resolution of the parameter for the expected type. The
method will only return if the expected type is one of the collection types
Array ,
Collection or
Map . An empty collection is only a valid resolution, if
the emptyCollection flag was set.
Parameters: container - Parameters: adapter - Parameters: expectedType - Parameters: expectedNameBinding - Parameters: useNames - Parameters: binding - throws: PicoCompositionException - |
|
|