T - the type of the event topic.P - the type of the event payload.public class GCUBEEvent<T extends GCUBETopic,P> extends Object
GCUBEProducers and consumed by GCUBEConsumers.
An event is about a GCUBETopic, carries a payload, has a creation timestamp, and is handled by a producer.
Through type instantiation, events may be constrained to be about GCUBETopics and/or
carry given payloads. For example:
a GCUBEEvent<MyTopic,Object> is about a MyTopic but can carry any payload.
a GCUBEEvent<GCUBETopic,MyPayload> is about any GCUBETopic but carries
a MyPayload.
a GCUBEEvent<MyTopic,MyPayload> is about a MyTopic and carries
a MyPayload.
Type constraints may be specified when the event is created, e.g.:
GCUBEEvent<MyTopic,MyPayload> myEvent = new GCUBEEvent<MyTopic,MyPayload>();
or else by subclassing, e.g.
public class MyEvent extends GCUBEEvent<MyTopic,MyPayload> {...}
...
MyEvent myEvent = new MyEvent();
GCUBETopic,
GCUBEProducer,
GCUBEConsumer| Modifier and Type | Field and Description |
|---|---|
protected P |
payload
The payload of the event.
|
protected GCUBEProducer<? super T,? super P> |
producer
The producer of the event.
|
protected Calendar |
timeStamp
The creation timestamp of the event.
|
protected T |
topic
The topic of the event.
|
| Constructor and Description |
|---|
GCUBEEvent() |
| Modifier and Type | Method and Description |
|---|---|
P |
getPayload()
Returns the payload of the event.
|
GCUBEProducer<? super T,? super P> |
getProducer()
Returns the producer which handled the event.
|
Calendar |
getTimeStamp()
Returns the timestamp of the event.
|
T |
getTopic()
Returns the topic of the event.
|
boolean |
isExpired(Calendar time)
Indicates whether the event has expired at a given time (typically the current time).
|
void |
setPayload(P payload)
Sets the payload of the event.
|
protected void |
setProducer(GCUBEProducer<? super T,? super P> producer)
Sets the producer which handles the event.
|
protected void |
setTopic(T topic)
Sets the topic of the event.
|
protected final Calendar timeStamp
protected T extends GCUBETopic topic
protected P payload
protected GCUBEProducer<? super T extends GCUBETopic,? super P> producer
protected void setTopic(T topic)
topic - the topic.public T getTopic()
public P getPayload()
public void setPayload(P payload)
payload - public GCUBEProducer<? super T,? super P> getProducer()
protected void setProducer(GCUBEProducer<? super T,? super P> producer)
producer - the producer.public Calendar getTimeStamp()
public boolean isExpired(Calendar time)
time - the time.true if it has, false otherwise.Copyright © 2015. All Rights Reserved.