extvisitor
Class AExtVisitorHost<I,H extends IExtVisitorHost<I,? extends H>>

java.lang.Object
  extended by extvisitor.AExtVisitorHost<I,H>
Type Parameters:
I - The type of the index value that is being used.
H - The type of the concrete SUBCLASS that extends this class.
All Implemented Interfaces:
IExtVisitorHost<I,H>, java.io.Serializable
Direct Known Subclasses:
ADataPacket, AStatus

public abstract class AExtVisitorHost<I,H extends IExtVisitorHost<I,? extends H>>
extends java.lang.Object
implements IExtVisitorHost<I,H>

Abstract implementation of IExtVisitorHost that provides defines a host by an index value and thus, a concrete execute method.
Usage:

   
 public class MyExtVisitorHost extends AExtVisitorHost<MyIndex, MyExtVisitorHost> {...}
 

Author:
Stephen Wong (c) 2010
See Also:
Serialized Form

Field Summary
private  I idx
          The index value that is associated with this host object
private static long serialVersionUID
           
 
Constructor Summary
AExtVisitorHost(I idx)
          Constructor for the class.
 
Method Summary
<R,P> R
execute(IExtVisitor<R,I,P,? extends H> algo, P... params)
          "Accept" method of the visitor design pattern that executes a given extended visitor by calling the associated indexed case of the visitor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

idx

private I idx
The index value that is associated with this host object

Constructor Detail

AExtVisitorHost

public AExtVisitorHost(I idx)
Constructor for the class.

Parameters:
idx - The index value that is associated with this host object
Method Detail

execute

public <R,P> R execute(IExtVisitor<R,I,P,? extends H> algo,
                       P... params)
"Accept" method of the visitor design pattern that executes a given extended visitor by calling the associated indexed case of the visitor. Returns algo.caseAt(idx, this, params) where idx is the index value stored in this host.

Specified by:
execute in interface IExtVisitorHost<I,H extends IExtVisitorHost<I,? extends H>>
Type Parameters:
R - The return type of the visitor.
P - The type of the input parameters of the visitor.
Parameters:
algo - The extended visitor to run, which must use the same index type as this host, and be able to run on a sub-class of this host.
params - Vararg input parameter to be used by the visitor.
Returns:
The result of running the associated indexed case of the visitor method.