Class ChannelCache<K,C extends Channel,A>

java.lang.Object
org.jdrupes.vmoperator.manager.events.ChannelCache<K,C,A>
Type Parameters:
K - the key type
C - the channel type
A - the type of the associated data

public class ChannelCache<K,C extends Channel,A> extends Object
A channel manager that tracks mappings from a key to a channel using “add/remove” (or “open/close”) events and the channels on which they are delivered.
  • Constructor Details

  • Method Details

    • both

      public Optional<ChannelCache.Both<C,A>> both(K key)
      Returns the channel and associates data registered for the key or an empty optional if no mapping exists.
      Parameters:
      key - the key
      Returns:
      the result
    • put

      public ChannelCache<K,C,A> put(K key, C channel, A associated)
      Store the given data.
      Parameters:
      key - the key
      channel - the channel
      associated - the associated
      Returns:
      the channel manager
    • put

      public ChannelCache<K,C,A> put(K key, C channel)
      Store the given data.
      Parameters:
      key - the key
      channel - the channel
      Returns:
      the channel manager
    • channel

      public Optional<C> channel(K key)
      Returns the channel registered for the key or an empty optional if no mapping exists.
      Parameters:
      key - the key
      Returns:
      the optional
    • associate

      public ChannelCache<K,C,A> associate(K key, A data)
      Associate the entry for the channel with the given data.

      The entry for the channel must already exist.

      Parameters:
      key - the key
      data - the data
      Returns:
      the channel manager
    • associated

      public Optional<A> associated(K key)
      Return the data associated with the entry for the channel.
      Parameters:
      key - the key
      Returns:
      the data
    • associated

      public Collection<A> associated()
      Returns all associated data.
      Returns:
      the collection
    • remove

      public void remove(String name)
      Removes the channel with the given name.
      Parameters:
      name - the name
    • keys

      public Set<K> keys()
      Returns all known keys.
      Returns:
      the sets the