Record Class ElementListenerMap.SnippetEntry

java.lang.Object
java.lang.Record
com.vaadin.flow.internal.nodefeature.ElementListenerMap.SnippetEntry
Record Components:
key - the key that the client sends the value under, not null
call - the call that the client runs, not null
sideEffect - the name of the method of the event that the client calls when the call returns a truthy value, or null if there is no side effect
filter - true if the entry is the filter of a listener, which is notified only when the value is truthy, even if the same call is also event data; false if it is only event data or has a side effect
mapElement - true if the call returns a DOM node that the client sends as the id of the closest state node, for event data of an Element; false otherwise
All Implemented Interfaces:
Serializable
Enclosing class:
ElementListenerMap

public static record ElementListenerMap.SnippetEntry(String key, JsCall call, @Nullable String sideEffect, boolean filter, boolean mapElement) extends Record
A function declared in the bundle, with the values it captures, that the client runs when an event occurs: a filter added with DomListenerRegistration.setFilterExpression(DomEventFilter) or event data added with DomListenerRegistration.addEventData(DomEventData). The client runs the call and sends the value it returns to the server under the key of the entry.

The key is @ followed by the key of the snippet, see JsCall.createSnippetKey().

An entry can have a side effect: the name of a method of the event, preventDefault or stopPropagation. The client then calls the method when the call returns a truthy value. This is used for addEventData("event.preventDefault()") on a listener with a declared filter: the event is prevented only when the filter passes. The key then ends with . and the name of the method, so it is different from the key of the filter itself. Such an entry is not a filter, as it doesn't decide which listeners are notified.

For internal use only. May be renamed or removed in a future release.

See Also:
  • Constructor Details

    • SnippetEntry

      public SnippetEntry(String key, JsCall call, @Nullable String sideEffect, boolean filter, boolean mapElement)
      Creates an instance of a SnippetEntry record class.
      Parameters:
      key - the value for the key record component
      call - the value for the call record component
      sideEffect - the value for the sideEffect record component
      filter - the value for the filter record component
      mapElement - the value for the mapElement record component
  • Method Details

    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • key

      public String key()
      Returns the value of the key record component.
      Returns:
      the value of the key record component
    • call

      public JsCall call()
      Returns the value of the call record component.
      Returns:
      the value of the call record component
    • sideEffect

      public @Nullable String sideEffect()
      Returns the value of the sideEffect record component.
      Returns:
      the value of the sideEffect record component
    • filter

      public boolean filter()
      Returns the value of the filter record component.
      Returns:
      the value of the filter record component
    • mapElement

      public boolean mapElement()
      Returns the value of the mapElement record component.
      Returns:
      the value of the mapElement record component