org.picocontainer.parameters
Class NullParameter

java.lang.Object
  extended by org.picocontainer.parameters.AbstractParameter
      extended by org.picocontainer.parameters.NullParameter
All Implemented Interfaces:
Serializable, Parameter

public class NullParameter
extends AbstractParameter
implements Serializable

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:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.picocontainer.Parameter
Parameter.DelegateResolver, Parameter.NotResolved, Parameter.Resolver, Parameter.ValueResolver
 
Field Summary
static NullParameter INSTANCE
          The one and only instance of null parameter.
 
Fields inherited from interface org.picocontainer.Parameter
DEFAULT, ZERO
 
Constructor Summary
protected NullParameter()
          Only once instance of Null parameter needed.
 
Method Summary
 void accept(PicoVisitor visitor)
          Accepts a visitor for this Parameter.
protected  boolean isAssignable(Type expectedType)
          Nulls cannot be assigned to primitives.
 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.
 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
 
Methods inherited from class org.picocontainer.parameters.AbstractParameter
isResolvable, resolveInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static final NullParameter INSTANCE
The one and only instance of null parameter.

Constructor Detail

NullParameter

protected NullParameter()
Only once instance of Null parameter needed.

Method Detail

accept

public void accept(PicoVisitor visitor)
Accepts a visitor for this Parameter. The method is normally called by visiting a ComponentAdapter, that cascades the visitor also down to all its Parameters.

Specified by:
accept in interface Parameter
Parameters:
visitor - the visitor.
See Also:
Parameter.accept(org.picocontainer.PicoVisitor)

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:
resolve in interface Parameter
Parameters:
container - the container from which dependencies are resolved.
forAdapter - the ComponentAdapter that is asking for the instance
injecteeAdapter - the adapter to be injected into (null for N/A)
expectedType - the required type
expectedNameBinding - Expected parameter name
useNames - should use parameter names for disambiguation
binding - @return true if 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,
                   Type expectedType,
                   NameBinding expectedNameBinding,
                   boolean useNames,
                   Annotation binding)
Verify that the Parameter can satisfy the expected type using the container

Specified by:
verify in interface Parameter
Parameters:
container - the container from which dependencies are resolved.
adapter - the ComponentAdapter that is asking for the verification
expectedType - the required type
expectedNameBinding - 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(Type expectedType)
Nulls cannot be assigned to primitives.

Parameters:
expectedType -
Returns:


Copyright © 2003-2010 Codehaus. All Rights Reserved.