org.perfectjpattern.core.api.behavioral.chainofresponsibility
Class NullHandler

java.lang.Object
  extended by org.perfectjpattern.core.api.behavioral.chainofresponsibility.NullHandler
All Implemented Interfaces:
IHandler<Object>, ISingleton

public final class NullHandler
extends Object
implements IHandler<Object>, ISingleton

Null Object Pattern implementation of IHandler.

NullHandler is a Singleton therefore it may not be directly instantiated, neither it may be extended.

Version:
$Revision: 1.0 $ $Date: Jun 23, 2007 1:40:23 PM $
Author:
Giovanni Azua
 

Method Summary
 boolean canHandle(Object aRequest)
          Returns true if this IHandler can handle the given request, false otherwise.
static NullHandler getInstance()
          Returns Singleton instance of NullHandler.
 IHandler<Object> getSuccessor()
          Returns the Successor handler.
 void handle(Object aRequest)
          Handle the given request.
 void setChainStrategy(IChainStrategy aStrategy)
          Set the IChainStrategy to this IHandler.
 void setSuccessor(IHandler<Object> aSuccessor)
          Sets the Successor element.
 void start(Object aRequest)
          Triggers execution of the Chain if the target Handler is the first reference, otherwise implements the decision-making regarding forwarding the request to its successor IHandler instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static NullHandler getInstance()
Returns Singleton instance of NullHandler.

Returns:
Singleton instance of NullHandler.

getSuccessor

public IHandler<Object> getSuccessor()
                              throws UnsupportedOperationException
Returns the Successor handler.

Specified by:
getSuccessor in interface IHandler<Object>
Returns:
Successor handler.
Throws:
UnsupportedOperationException

start

public void start(Object aRequest)
           throws IllegalArgumentException
Triggers execution of the Chain if the target Handler is the first reference, otherwise implements the decision-making regarding forwarding the request to its successor IHandler instance.

Specified by:
start in interface IHandler<Object>
Parameters:
aRequest - Context-specific request to handle.
Throws:
IllegalArgumentException - 'aRequest' must not be null.

canHandle

public boolean canHandle(Object aRequest)
                  throws IllegalArgumentException
Returns true if this IHandler can handle the given request, false otherwise.

Specified by:
canHandle in interface IHandler<Object>
Parameters:
aRequest - Context-specific request to handle.
Returns:
true if this IHandler can handle the given request, false otherwise.
Throws:
IllegalArgumentException - 'aRequest' must not be null.

handle

public void handle(Object aRequest)
Handle the given request. Implements the actual handling logic and must not contain any decision-making regarding e.g. forwarding the request.

Specified by:
handle in interface IHandler<Object>
Parameters:
aRequest - Context-specific request to handle.

setSuccessor

public void setSuccessor(IHandler<Object> aSuccessor)
                  throws UnsupportedOperationException
Sets the Successor element.

Specified by:
setSuccessor in interface IHandler<Object>
Parameters:
aSuccessor - Successor handler
Throws:
UnsupportedOperationException

setChainStrategy

public void setChainStrategy(IChainStrategy aStrategy)
                      throws IllegalArgumentException
Set the IChainStrategy to this IHandler. IChainStrategy allows to easily modify how the Chain should behave. Possible implementations are e.g.

Specified by:
setChainStrategy in interface IHandler<Object>
Parameters:
aStrategy - Continuation strategy defines how the chain should behave
Throws:
IllegalArgumentException - 'aStrategy' must not be null.


Copyright © 2007-2009. All Rights Reserved.