Package org.picocontainer.parameters
Class NullParameter
- java.lang.Object
-
- org.picocontainer.parameters.AbstractParameter
-
- org.picocontainer.parameters.NullParameter
-
- All Implemented Interfaces:
java.io.Serializable,Parameter
public class NullParameter extends AbstractParameter implements java.io.Serializable
Once in a great while, you actually want to pass in 'null' as an argument. Instead of bypassing the type checking mechanisms available inConstantParameter, we provide a Special Type geared to marking nulls.- Author:
- Michael Rimov
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.picocontainer.Parameter
Parameter.DelegateResolver, Parameter.NotResolved, Parameter.Resolver, Parameter.ValueResolver
-
-
Field Summary
Fields Modifier and Type Field Description static NullParameterINSTANCEThe one and only instance of null parameter.
-
Constructor Summary
Constructors Modifier Constructor Description protectedNullParameter()Only once instance of Null parameter needed.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(PicoVisitor visitor)Accepts a visitor for this Parameter.protected booleanisAssignable(java.lang.reflect.Type expectedType)Nulls cannot be assigned to primitives.Parameter.Resolverresolve(PicoContainer container, ComponentAdapter<?> forAdapter, ComponentAdapter<?> injecteeAdapter, java.lang.reflect.Type expectedType, NameBinding expectedNameBinding, boolean useNames, java.lang.annotation.Annotation binding)Check if the Parameter can satisfy the expected type using the container.voidverify(PicoContainer container, ComponentAdapter<?> adapter, java.lang.reflect.Type expectedType, NameBinding expectedNameBinding, boolean useNames, java.lang.annotation.Annotation binding)Verify that the Parameter can satisfy the expected type using the container-
Methods inherited from class org.picocontainer.parameters.AbstractParameter
isResolvable, resolveInstance
-
-
-
-
Field Detail
-
INSTANCE
public static final NullParameter INSTANCE
The one and only instance of null parameter.
-
-
Method Detail
-
accept
public void accept(PicoVisitor visitor)
Accepts a visitor for this Parameter. The method is normally called by visiting aComponentAdapter, that cascades the visitor also down to all its Parameters.- Specified by:
acceptin interfaceParameter- Parameters:
visitor- the visitor.- See Also:
Parameter.accept(org.picocontainer.PicoVisitor)
-
resolve
public Parameter.Resolver resolve(PicoContainer container, ComponentAdapter<?> forAdapter, ComponentAdapter<?> injecteeAdapter, java.lang.reflect.Type expectedType, NameBinding expectedNameBinding, boolean useNames, java.lang.annotation.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 disambiguation- Returns:
trueif the component parameter can be resolved.- See Also:
Parameter.resolve(org.picocontainer.PicoContainer, org.picocontainer.ComponentAdapter, org.picocontainer.ComponentAdapter, java.lang.reflect.Type, org.picocontainer.NameBinding, boolean, java.lang.annotation.Annotation)
-
verify
public void verify(PicoContainer container, ComponentAdapter<?> adapter, java.lang.reflect.Type expectedType, NameBinding expectedNameBinding, boolean useNames, java.lang.annotation.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 name- See Also:
Parameter.verify(org.picocontainer.PicoContainer, org.picocontainer.ComponentAdapter, java.lang.reflect.Type, org.picocontainer.NameBinding, boolean, java.lang.annotation.Annotation)
-
isAssignable
protected boolean isAssignable(java.lang.reflect.Type expectedType)
Nulls cannot be assigned to primitives.- Parameters:
expectedType-- Returns:
-
-