Package dev.getelements.elements.sdk
Interface Event
public interface Event
Represents an event to be handled by
Element
instances.-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
All event names with the following prefix are considered system events. -
Method Summary
Modifier and TypeMethodDescriptionstatic Event.Builder
builder()
Returns a newEvent.Builder
forEvent
instances.default <T> T
getEventArgument
(int index) Gets the argument at the specified index.default <T> T
getEventArgument
(int index, Class<T> type) Gets the argument at the specified index.Get the arguments of theEvent
.TheEvent
name.default boolean
True if the event is a system event.
-
Field Details
-
SYSTEM_EVENT_PREFIX
All event names with the following prefix are considered system events. Applications should not use events prefixed with this string.- See Also:
-
-
Method Details
-
isSystemEvent
default boolean isSystemEvent()True if the event is a system event.- Returns:
- true if system event, false otherwise.
-
getEventName
String getEventName()TheEvent
name. The names of events are application specific. However, they should follow a globally unique naming pattern. Additionally,SYSTEM_EVENT_PREFIX
prefixed events are reserved for the SDK and should not be used.- Returns:
- the name of hte event.
-
getEventArguments
Get the arguments of theEvent
. When using argument-based matching, each argument must be non-null and must match based on exact class type. The dispatch mechanism does not honor polymorphism.- Returns:
- the arguments
-
getEventArgument
default <T> T getEventArgument(int index) Gets the argument at the specified index. The index must be within the bounds of the event arguments list.- Type Parameters:
T
- the type of the argument to retrieve- Parameters:
index
- the index of the argument to retrieve- Returns:
- the argument at the specified index
-
getEventArgument
Gets the argument at the specified index. The index must be within the bounds of the event arguments list. Similar togetEventArgument(int)
, thie enforces more predictable exception behavior by requiring the type to be explicitly named in the method call.- Type Parameters:
T
- the type of the argument to retrieve- Parameters:
index
- the index of the argument to retrieve- Returns:
- the argument at the specified index
-
builder
Returns a newEvent.Builder
forEvent
instances.- Returns:
- the
Event.Builder
-