CALLBACKTYPE - The callback type.@ThreadSafe public class CallbackList<CALLBACKTYPE extends ICallback> extends Object implements ICallbackList<CALLBACKTYPE>, ICloneable<CallbackList<CALLBACKTYPE>>
| Constructor and Description |
|---|
CallbackList() |
CallbackList(CallbackList<CALLBACKTYPE> aOther) |
| Modifier and Type | Method and Description |
|---|---|
CallbackList<CALLBACKTYPE> |
addCallback(CALLBACKTYPE aCallback)
Add a callback.
|
void |
forEach(Consumer<CALLBACKTYPE> aConsumer)
Invoke all registered callbacks in a safe manner.
|
EContinue |
forEachWithReturn(Function<CALLBACKTYPE,EContinue> aFunction)
Invoke all registered callbacks in a safe manner.
|
ICommonsList<CALLBACKTYPE> |
getAllCallbacks() |
CALLBACKTYPE |
getCallbackAtIndex(int nIndex)
Get the callback at the specified index.
|
int |
getCallbackCount() |
CallbackList<CALLBACKTYPE> |
getClone() |
boolean |
hasCallbacks() |
EChange |
removeAllCallbacks()
Remove all callbacks
|
EChange |
removeCallback(CALLBACKTYPE aCallback)
Remove the specified callback
|
String |
toString() |
public CallbackList()
public CallbackList(@Nonnull CallbackList<CALLBACKTYPE> aOther)
@Nonnull public CallbackList<CALLBACKTYPE> addCallback(@Nonnull CALLBACKTYPE aCallback)
aCallback - May not be null.@Nonnull public EChange removeCallback(@Nullable CALLBACKTYPE aCallback)
aCallback - May be null.EChange@Nonnull public EChange removeAllCallbacks()
EChange@Nonnull @ReturnsMutableCopy public ICommonsList<CALLBACKTYPE> getAllCallbacks()
getAllCallbacks in interface ICallbackList<CALLBACKTYPE extends ICallback>null and only
containing non-null elements.@Nullable public CALLBACKTYPE getCallbackAtIndex(@Nonnegative int nIndex)
ICallbackListgetCallbackAtIndex in interface ICallbackList<CALLBACKTYPE extends ICallback>nIndex - The index to be retrieved. Should be ≥ 0.null if the provided index is invalid.@Nonnegative public int getCallbackCount()
getCallbackCount in interface ICallbackList<CALLBACKTYPE extends ICallback>public boolean hasCallbacks()
hasCallbacks in interface ICallbackList<CALLBACKTYPE extends ICallback>true if at least a single callback is present,
false otherwise.@Nonnull public CallbackList<CALLBACKTYPE> getClone()
getClone in interface ICloneable<CallbackList<CALLBACKTYPE extends ICallback>>public void forEach(@Nonnull Consumer<CALLBACKTYPE> aConsumer)
ICallbackListforEach in interface ICallbackList<CALLBACKTYPE extends ICallback>aConsumer - The action to be performed with the respective callback. This method
cannot return a value. May not be null.@Nonnull public EContinue forEachWithReturn(@Nonnull Function<CALLBACKTYPE,EContinue> aFunction)
ICallbackListforEachWithReturn in interface ICallbackList<CALLBACKTYPE extends ICallback>aFunction - The action to be performed with the respective callback. The first
callback that returns EContinue.BREAK stops the process. May
not be null.EContinue.CONTINUE if all callbacks returned
EContinue.CONTINUE, EContinue.BREAK if at least one
invocation returned EContinue.BREAK.Copyright © 2014–2016 Philip Helger. All rights reserved.