Package org.picocontainer.parameters
Class NullParameter
java.lang.Object
org.picocontainer.parameters.AbstractParameter
org.picocontainer.parameters.NullParameter
- All Implemented Interfaces:
Serializable,Parameter
Once in a great while, you actually want to pass in 'null' as an argument. Instead
of bypassing the type checking mechanisms available in
ConstantParameter, we provide a Special Type
geared to marking nulls.- Author:
- Michael Rimov
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.picocontainer.Parameter
Parameter.DelegateResolver, Parameter.NotResolved, Parameter.Resolver, Parameter.ValueResolver -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final NullParameterThe one and only instance of null parameter. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedOnly once instance of Null parameter needed. -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(PicoVisitor visitor) Accepts a visitor for this Parameter.protected booleanisAssignable(Type expectedType) Nulls cannot be assigned to primitives.resolve(PicoContainer container, ComponentAdapter<?> forAdapter, ComponentAdapter<?> injecteeAdapter, Type expectedType, NameBinding expectedNameBinding, boolean useNames, Annotation binding) Check if the Parameter can satisfy the expected type using the container.voidverify(PicoContainer container, ComponentAdapter<?> adapter, Type expectedType, NameBinding expectedNameBinding, boolean useNames, Annotation binding) Verify that the Parameter can satisfy the expected type using the containerMethods inherited from class org.picocontainer.parameters.AbstractParameter
isResolvable, resolveInstance
-
Field Details
-
INSTANCE
The one and only instance of null parameter.
-
-
Constructor Details
-
NullParameter
protected NullParameter()Only once instance of Null parameter needed.
-
-
Method Details
-
accept
Accepts a visitor for this Parameter. The method is normally called by visiting aComponentAdapter, that cascades the visitor also down to all its Parameters. -
resolve
public Parameter.Resolver resolve(PicoContainer container, ComponentAdapter<?> forAdapter, ComponentAdapter<?> injecteeAdapter, Type expectedType, NameBinding expectedNameBinding, boolean useNames, Annotation binding) Check if the Parameter can satisfy the expected type using the container.- Specified by:
resolvein interfaceParameter- Parameters:
container- the container from which dependencies are resolved.forAdapter- theComponentAdapterthat is asking for the instanceinjecteeAdapter- the adapter to be injected into (null for N/A)expectedType- the required typeexpectedNameBinding- Expected parameter nameuseNames- should use parameter names for disambiguationbinding- @returntrueif the component parameter can be resolved.- See Also:
-
verify
public void verify(PicoContainer container, ComponentAdapter<?> adapter, Type expectedType, NameBinding expectedNameBinding, boolean useNames, Annotation binding) Verify that the Parameter can satisfy the expected type using the container- Specified by:
verifyin interfaceParameter- Parameters:
container- the container from which dependencies are resolved.adapter- theComponentAdapterthat is asking for the verificationexpectedType- the required typeexpectedNameBinding- Expected parameter nameuseNames-binding-- See Also:
-
isAssignable
Nulls cannot be assigned to primitives.- Parameters:
expectedType-- Returns:
-