public class Event extends Object
Constructor and Description |
---|
Event()
Construct empty event.
|
Event(Class<?> type)
Creates a new event with the specified data type but data still being
null . |
Event(Class<?> type,
Object data)
Creates a new event with the specified data type and contents.
|
Event(Scope scope,
Class<?> type,
Object data)
Creates a new event that can be send to scope.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addCause(EventId id)
Adds the id of one event to the causes of this event.
|
boolean |
equals(Object obj) |
Set<EventId> |
getCauses()
Returns all causing events marked so far.
|
Object |
getData() |
EventId |
getId()
Returns the id of the event.
|
MetaData |
getMetaData()
Returns a
MetaData instance representing the meta data for this
event. |
String |
getMethod() |
Scope |
getScope() |
ParticipantId |
getSenderId()
Deprecated.
use
getId() instead |
long |
getSequenceNumber()
Deprecated.
use
getId() instead |
Class<?> |
getType() |
int |
hashCode() |
boolean |
isCause(EventId id)
Tells whether the id of one event is already marked as a cause of this
event.
|
boolean |
removeCause(EventId id)
Removes a causing event from the set of causes for this event.
|
void |
setData(Object data) |
void |
setId(EventId id)
Sets the id of this event.
|
void |
setId(ParticipantId senderId,
long sequenceNumber)
Sets all information necessary to generate the
EventId of this
event. |
void |
setMethod(String method) |
void |
setScope(Scope scope) |
void |
setType(Class<?> type) |
String |
toString() |
public Event(Scope scope, Class<?> type, Object data)
scope
- The scope to which the event will be sent.type
- A class object indicating the class of the data being sent in
the event.data
- The actual data that should be sent in the event.public Event(Class<?> type)
null
.type
- class object describing the data typepublic Event(Class<?> type, Object data)
type
- class object describing the data typedata
- the data this event shall containg. Must match the declared
typepublic Event()
public Class<?> getType()
null
to express
a void type where no payload is carried at all.public void setType(Class<?> type)
type
- the Java type to set for the Event payloadpublic Object getData()
public void setData(Object data)
data
- the data to setpublic Scope getScope()
public void setId(ParticipantId senderId, long sequenceNumber)
EventId
of this
event. After this call getId()
is able to return an id.senderId
- id of the sending participant for this eventsequenceNumber
- sequence number within the specified participantpublic void setId(EventId id)
getId()
can return an id.id
- new id to set@Deprecated public ParticipantId getSenderId()
getId()
insteadIllegalStateException
- the id is not yet defined because the event was not sent by
an Informer
so farpublic void setScope(Scope scope)
scope
- the scope to set@Deprecated public long getSequenceNumber()
getId()
insteadIllegalStateException
- the id is not yet defined because the event was not sent by
an Informer
so farpublic EventId getId()
IllegalStateException
- no id available so farpublic MetaData getMetaData()
MetaData
instance representing the meta data for this
event.null
public String getMethod()
public void setMethod(String method)
method
- the method to setpublic boolean addCause(EventId id)
id
- the id of a causing eventtrue
if the causes was added, false
if
it already existedpublic boolean removeCause(EventId id)
id
- of the causing eventtrue
if an event with this id was removed from the
causes, else false
public boolean isCause(EventId id)
id
- id of the event to test causality fortrue
if id is marked as a cause for this event, else
false
Copyright © 2018 CoR-Lab. All rights reserved.