Package adams.flow.core
Class Token
- java.lang.Object
-
- adams.flow.core.Token
-
- All Implemented Interfaces:
CloneHandler<Token>,Serializable
- Direct Known Subclasses:
NullToken
public class Token extends Object implements Serializable, CloneHandler<Token>
A wrapper object for passing data through the flow.
If enabled, provenance information can be stored as well.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TokengetClone()Returns a clone of itself.ObjectgetPayload()Returns the payload.<T> TgetPayload(Class<T> cls)Returns the payload properly casted.inthashCode()Returns the hashcode for the object.booleanhasPayload(Class cls)Checks whether the payload is of the specified type (or a subclass; or implements this interface).booleanisArray()Checks whether the payload is not null and an array.booleanisNull()Checks whether the payload is null.voidsetPayload(Object value)Sets the payload.StringtoString()Returns a string representation of the payload.StringunhandledData()Returns an error string with the class type of the payload.
-
-
-
Field Detail
-
m_Payload
protected Object m_Payload
the payload.
-
-
Constructor Detail
-
Token
public Token()
Initializes the token.
-
Token
public Token(Object payload)
Initializes the token.- Parameters:
payload- the payload for this token
-
-
Method Detail
-
setPayload
public void setPayload(Object value)
Sets the payload.- Parameters:
value- the new payload
-
isArray
public boolean isArray()
Checks whether the payload is not null and an array.- Returns:
- true if an array
-
hasPayload
public boolean hasPayload(Class cls)
Checks whether the payload is of the specified type (or a subclass; or implements this interface).- Parameters:
cls- the super class to check- Returns:
- true if a match
- See Also:
ClassLocator.matches(Class, Class)
-
getPayload
public Object getPayload()
Returns the payload.- Returns:
- the payload
-
getPayload
public <T> T getPayload(Class<T> cls)
Returns the payload properly casted.- Returns:
- the payload
-
isNull
public boolean isNull()
Checks whether the payload is null.- Returns:
- true if payload is null
-
getClone
public Token getClone()
Returns a clone of itself.- Specified by:
getClonein interfaceCloneHandler<Token>- Returns:
- the clone
- See Also:
ObjectCopyHelper.copyObject(Object)
-
hashCode
public int hashCode()
Returns the hashcode for the object.
-
unhandledData
public String unhandledData()
Returns an error string with the class type of the payload.- Returns:
- the error message
-
-