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 Token
getClone()
Returns a clone of itself.Object
getPayload()
Returns the payload.<T> T
getPayload(Class<T> cls)
Returns the payload properly casted.int
hashCode()
Returns the hashcode for the object.boolean
hasPayload(Class cls)
Checks whether the payload is of the specified type (or a subclass; or implements this interface).boolean
isArray()
Checks whether the payload is not null and an array.boolean
isNull()
Checks whether the payload is null.void
setPayload(Object value)
Sets the payload.String
toString()
Returns a string representation of the payload.String
unhandledData()
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:
getClone
in 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
-
-