Class StateEvent<T>
java.lang.Object
com.vaadin.hilla.signals.core.event.StateEvent<T>
- Type Parameters:
T- The type of the value of the event.
A utility class for representing state events out of an ObjectNode. This
helps to serialize and deserialize state events without getting involved with
the string literals for field names and event types.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumPossible types of state events.static final classThe field names used in the JSON representation of the state event.static classAn exception thrown when the event type is null or invalid.static class -
Constructor Summary
ConstructorsConstructorDescriptionStateEvent(com.fasterxml.jackson.databind.node.ObjectNode json, Class<T> valueType) Creates a new state event using the given JSON representation.StateEvent(String id, StateEvent.EventType eventType, T value) Creates a new state event using the given parameters.StateEvent(String id, StateEvent.EventType eventType, T value, T expected) Creates a new state event using the given parameters. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the type of the event.Returns the expected value of the event if exists.getId()Returns the unique identifier of the event.getValue()Returns the value of the event.inthashCode()static booleanisAccepted(com.fasterxml.jackson.databind.node.ObjectNode event) static com.fasterxml.jackson.databind.node.ObjectNodesetAccepted(com.fasterxml.jackson.databind.node.ObjectNode event, boolean accepted) com.fasterxml.jackson.databind.node.ObjectNodetoJson()Returns the JSON representation of the event.
-
Constructor Details
-
StateEvent
Creates a new state event using the given parameters.- Parameters:
id- The unique identifier of the event.eventType- The type of the event.value- The value of the event.expected- The expected value of the event before the change is applied.
-
StateEvent
Creates a new state event using the given parameters.- Parameters:
id- The unique identifier of the event.eventType- The type of the event.value- The value of the event.
-
StateEvent
Creates a new state event using the given JSON representation.- Parameters:
json- The JSON representation of the event.
-
-
Method Details
-
toJson
public com.fasterxml.jackson.databind.node.ObjectNode toJson()Returns the JSON representation of the event.- Returns:
- The JSON representation of the event.
-
setAccepted
public static com.fasterxml.jackson.databind.node.ObjectNode setAccepted(com.fasterxml.jackson.databind.node.ObjectNode event, boolean accepted) -
isAccepted
public static boolean isAccepted(com.fasterxml.jackson.databind.node.ObjectNode event) -
getId
Returns the unique identifier of the event.- Returns:
- The unique identifier of the event.
-
getEventType
Returns the type of the event.- Returns:
- The type of the event.
-
getValue
Returns the value of the event.- Returns:
- The value of the event.
-
getExpected
Returns the expected value of the event if exists.- Returns:
- The expected value of the event if exists.
-
equals
-
hashCode
public int hashCode()
-