Interface Registration

All Superinterfaces:
Serializable
All Known Subinterfaces:
DomListenerRegistration, ReturnChannelRegistration, StateTree.ExecutionRegistration
All Known Implementing Classes:
ShortcutRegistration, TopicConnectionRegistration
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface Registration extends Serializable
A registration object for removing an event listener added to a source.
Since:
1.0
Author:
Vaadin Ltd
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> Registration
    addAndRemove(Collection<T> collection, T item)
    Creates a registration by adding an item to a collection immediately and removing the item from the collection when the registration is removed.
    combine(Registration... registrations)
    Creates a registration that will remove multiple registrations.
    once(Command command)
    Creates a registration that will run a command only once.
    void
    Removes the associated listener from the event source.
  • Method Details

    • remove

      void remove()
      Removes the associated listener from the event source.

      The remove method called after removal does nothing.

      See Also:
    • once

      static Registration once(Command command)
      Creates a registration that will run a command only once. This makes it safe for the registration to be removed multiple times even in cases when the command should be run only once.
      Parameters:
      command - the command to run the first time the registration is removed, not null
      Returns:
      a registration that will invoke the command once, not null
      Since:
    • combine

      static Registration combine(Registration... registrations)
      Creates a registration that will remove multiple registrations.
      Parameters:
      registrations - the registrations to remove, not null
      Returns:
      a registration that removes all provided registrations, not null
      Since:
    • addAndRemove

      static <T> Registration addAndRemove(Collection<T> collection, T item)
      Creates a registration by adding an item to a collection immediately and removing the item from the collection when the registration is removed.

      Care should be used when using this pattern to iterate over a copy of the collection to avoid ConcurrentModificationException if a listener or other callback may trigger adding or removing registrations.

      Parameters:
      collection - the collection to which the item should be added and removed, not null
      item - the item to add and remove
      Returns:
      a registration that will remove the item from the collection, not null
      Since: