Class ChannelTracker<K,C extends Channel,A>
java.lang.Object
org.jdrupes.vmoperator.manager.events.ChannelTracker<K,C,A>
- Type Parameters:
K
- the key typeC
- the channel typeA
- the type of the associated data
- All Implemented Interfaces:
ChannelDictionary<K,
C, A>
public class ChannelTracker<K,C extends Channel,A>
extends Object
implements ChannelDictionary<K,C,A>
Used to track mapping from a key to a channel.
Entries must be maintained by handlers for “add/remove” (or “open/close”) events delivered on the channels that are to be made available by the tracker.
The channels are stored in the dictionary using WeakReference
s.
Removing entries is therefore best practice but not an absolute necessity
as entries for cleared references are removed when one of the methods
values()
, ChannelDictionary.channels()
or ChannelDictionary.associated()
is called.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jdrupes.vmoperator.manager.events.ChannelDictionary
ChannelDictionary.Value<C extends Channel,
A> -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAssociate the entry for the channel with the given data.keys()
Returns all known keys.Store the given data.Store the given data.void
Removes the channel with the given name.Returns the channel and associates data registered for the key or an empty optional if no mapping exists.values()
Return all known values.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.jdrupes.vmoperator.manager.events.ChannelDictionary
associated, associated, channel, channels
-
Constructor Details
-
ChannelTracker
public ChannelTracker()
-
-
Method Details
-
keys
Description copied from interface:ChannelDictionary
Returns all known keys. -
values
Description copied from interface:ChannelDictionary
Return all known values. -
value
Returns the channel and associates data registered for the key or an empty optional if no mapping exists. -
put
Store the given data.- Parameters:
key
- the keychannel
- the channelassociated
- the associated- Returns:
- the channel manager
-
put
Store the given data.- Parameters:
key
- the keychannel
- the channel- Returns:
- the channel manager
-
associate
Associate the entry for the channel with the given data.The entry for the channel must already exist.
- Parameters:
key
- the keydata
- the data- Returns:
- the channel manager
-
remove
Removes the channel with the given name.- Parameters:
name
- the name
-