Interface TimeSeries.Event<V>
- Type Parameters:
V
- query value type
- All Superinterfaces:
TimeSeries.EventMetadata
- Enclosing interface:
- TimeSeries
Two instances are equal
if and only if they
have identical attributes. Typically two Event instances that have the
same sequence number will be equal, but this may not be true if the event
has changed on the server – see Changes to a time series made
outside the API in the TimeSeries
documentation.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Return whether this is an edit event.If this is an edit event, returns the metadata of the original event that this event replaces; otherwise returns this event.value()
The value associated with the event.<T> TimeSeries.Event<T>
withValue
(T newValue) Clone this event with a different value.Methods inherited from interface com.pushtechnology.diffusion.client.features.TimeSeries.EventMetadata
author, sequence, timestamp
-
Method Details
-
value
V value()The value associated with the event.- Returns:
- event value
-
originalEvent
TimeSeries.EventMetadata originalEvent()If this is an edit event, returns the metadata of the original event that this event replaces; otherwise returns this event.The result is always the metadata of an original event, never that of an edit event.
- Returns:
- if equal to
this
, this is not an edit event; otherwise, the sequence number of the event replaced by this edit event
-
isEditEvent
boolean isEditEvent()Return whether this is an edit event.x.isEditEvent()
is equivalent tox.originalEvent() != x
.- Returns:
- true if this is an edit event, otherwise this is an original event
-
withValue
Clone this event with a different value.This method is useful when further transformation of the received value is needed, but the application wishes to preserve other event attributes. For example, if a Bytes value is received which the session wishes to interpret as JSON, it can do the following.
Event<JSON> transformToJSON(Event<Bytes> bytesEvent) { JSON json = Diffusion.dataTypes().json().readValue(bytesEvent.value(); return bytesEvent.withValue(json); }
All attributes other than the value will be copied from this event. The result will only equal this event if newValue equals this event's value.
- Type Parameters:
T
- the new value type- Returns:
- a copy of this event with a different value
-