T
- The type of the wrapped objectpublic class Event<T> extends Object implements Serializable, Recyclable
Consumer
s.Modifier and Type | Class and Description |
---|---|
static class |
Event.Headers
Headers are a Map-like structure of name-value pairs.
|
Constructor and Description |
---|
Event(Class<T> klass)
Creates a new Event based on the type T of
|
Event(Event.Headers headers,
T data)
Creates a new Event with the given
headers and data . |
Event(Event.Headers headers,
T data,
Consumer<Throwable> errorConsumer)
|
Event(T data)
Creates a new Event with the given
data . |
Modifier and Type | Method and Description |
---|---|
void |
consumeError(Throwable throwable)
Consumes error, using a producer defined callback
|
Event<T> |
copy()
Create a copy of this event, reusing same headers, data and replyTo
|
<E> Event<E> |
copy(E data)
Create a copy of this event, reusing same headers and replyTo
|
T |
getData()
Get the internal data being wrapped.
|
Consumer<Throwable> |
getErrorConsumer()
Get the internal error consumer callback being wrapped.
|
Event.Headers |
getHeaders()
Get the
Event.Headers attached to this event. |
UUID |
getId()
Get the globally-unique id of this event.
|
Object |
getKey()
Get the key this event was notified on.
|
Object |
getReplyTo()
Get the key to send replies to.
|
void |
override(Event<T> ev) |
void |
recycle()
Free any internal resources and reset the state of the object to enable reuse.
|
Event<T> |
setData(T data)
Set the internal data to wrap.
|
Event<T> |
setKey(Object key)
Set the key this event is being notified with.
|
Event<T> |
setReplyTo(Object replyTo)
Set the
key that interested parties should send replies to. |
String |
toString() |
static <T> Event<T> |
wrap(T obj)
Wrap the given object with an
Event . |
static <T> Event<T> |
wrap(T obj,
Object replyToKey)
|
public Event(Event.Headers headers, T data)
headers
and data
.headers
- The headersdata
- The datapublic Event(Event.Headers headers, T data, Consumer<Throwable> errorConsumer)
headers
- The headersdata
- The dataerrorConsumer
- error consumer callbackpublic Event(T data)
data
. The event will have empty headers.data
- The datapublic static <T> Event<T> wrap(T obj)
Event
.obj
- The object to wrap.Event
.public static <T> Event<T> wrap(T obj, Object replyToKey)
T
- The type of the given object.obj
- The object to wrap.replyToKey
- The key to use as a replyTo.Event
.public UUID getId()
UUID
of this event.public Event.Headers getHeaders()
Event.Headers
attached to this event.public Object getReplyTo()
public Event<T> setReplyTo(Object replyTo)
key
that interested parties should send replies to.replyTo
- The key to use to notify sender of replies.public Object getKey()
public Event<T> setKey(Object key)
key
- The key used to notify consumers of this event.public T getData()
public Event<T> setData(T data)
data
- Data to wrap.public Consumer<Throwable> getErrorConsumer()
public Event<T> copy()
public <E> Event<E> copy(E data)
public void consumeError(Throwable throwable)
throwable
- The error to consumepublic void recycle()
Recyclable
recycle
in interface Recyclable
Copyright © 2017. All rights reserved.