Class ChannelManager<K,C extends Channel,A>
java.lang.Object
org.jdrupes.vmoperator.manager.events.ChannelManager<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 ChannelManager<K,C extends Channel,A>
extends Object
implements ChannelDictionary<K,C,A>
Provides an actively managed implementation of the
ChannelDictionary
.The ChannelManager
can be used for housekeeping by any component
that creates channels. It can be shared between this component and
some other component, preferably passing it as ChannelDictionary
(the read-only view) to the second component. Alternatively, the other
component can use a ChannelTracker
to track the mappings using
events.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jdrupes.vmoperator.manager.events.ChannelDictionary
ChannelDictionary.Value<C extends Channel,
A> -
Constructor Summary
ConstructorDescriptionInstantiates a new channel manager without a default supplier.ChannelManager
(Function<K, C> supplier) Instantiates a new channel manager. -
Method Summary
Modifier and TypeMethodDescriptionAssociate the entry for the channel with the given data.channelGet
(K key) Returns theChannel
for the given name, creating it using the supplier passed to the constructor if it doesn’t exist yet.computeIfAbsent
(K key, Function<K, C> supplier) Returns theChannel
for the given name, creating it using the given supplier if it doesn’t exist yet.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
-
ChannelManager
Instantiates a new channel manager.- Parameters:
supplier
- the supplier that creates new channels
-
ChannelManager
public ChannelManager()Instantiates a new channel manager without a default supplier.
-
-
Method Details
-
keys
Description copied from interface:ChannelDictionary
Returns all known keys. -
values
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
-
channelGet
Returns theChannel
for the given name, creating it using the supplier passed to the constructor if it doesn’t exist yet.- Parameters:
key
- the key- Returns:
- the channel
-
computeIfAbsent
Returns theChannel
for the given name, creating it using the given supplier if it doesn’t exist yet.- Parameters:
key
- the keysupplier
- the supplier- Returns:
- the channel
-
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
-