Don't add channels until fully initialized.

This commit is contained in:
Michael Lipp 2025-01-28 18:08:28 +01:00
parent 85be5b9cbf
commit 5cd4edcec1
2 changed files with 19 additions and 0 deletions

View file

@ -62,6 +62,11 @@ public class ChannelManager<K, C extends Channel, A>
this(k -> null);
}
/**
* Return all keys.
*
* @return the keys.
*/
@Override
public Set<K> keys() {
return entries.keySet();
@ -113,6 +118,18 @@ public class ChannelManager<K, C extends Channel, A>
return this;
}
/**
* Creates a new channel without adding it to the channel manager.
* After fully initializing the channel, it should be added to the
* manager using {@link #put(K, C)}.
*
* @param key the key
* @return the c
*/
public C createChannel(K key) {
return supplier.apply(key);
}
/**
* Returns the {@link Channel} for the given name, creating it using
* the supplier passed to the constructor if it doesn't exist yet.