Package com.helger.commons.callback
Class CallbackList<CALLBACKTYPE extends ICallback>
java.lang.Object
com.helger.commons.callback.CallbackList<CALLBACKTYPE>
- Type Parameters:
CALLBACKTYPE- The callback type.
- All Implemented Interfaces:
ICallbackList<CALLBACKTYPE>,ICommonsIterable<CALLBACKTYPE>,ICloneable<CallbackList<CALLBACKTYPE>>,IHasSize,Iterable<CALLBACKTYPE>
@ThreadSafe
public class CallbackList<CALLBACKTYPE extends ICallback>
extends Object
implements ICallbackList<CALLBACKTYPE>, ICloneable<CallbackList<CALLBACKTYPE>>
This class manages a list of callbacks. In reality it is a Set of callbacks.
- Author:
- Philip Helger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(CALLBACKTYPE aCallback) Add a callback.final EChangeaddAll(CALLBACKTYPE... aCallbacks) Add an array of elements to this collection.voidforEach(Consumer<? super CALLBACKTYPE> aConsumer) forEachBreakable(Function<? super CALLBACKTYPE, EContinue> aFunction) A special version ofIterable.forEach(Consumer)that can break iteration if a certain requirement is fulfilled.getCallbackAtIndex(int nIndex) Get the callback at the specified index.getClone()booleanisEmpty()iterator()Remove all callbacksremoveObject(CALLBACKTYPE aCallback) Remove the specified callbackset(CALLBACKTYPE aCallback) Clear all elements and add only the passed value.set(CallbackList<CALLBACKTYPE> rhs) Clear all elements and add all provided values.intsize()toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.helger.commons.collection.impl.ICommonsIterable
containsAny, containsNone, containsOnly, findAll, findAllInstanceOf, findAllMapped, findAllMapped, findAllMapped, findFirst, findFirst, findFirstIndex, findFirstMapped, findFirstMapped, findLastIndex, forEachByIndex, forEachThrowing, getCount, getCountMethods inherited from interface com.helger.commons.lang.IHasSize
isNotEmptyMethods inherited from interface java.lang.Iterable
spliterator
-
Constructor Details
-
CallbackList
public CallbackList() -
CallbackList
-
-
Method Details
-
set
Clear all elements and add all provided values. If no value is provided,the collection is empty afterwards.- Parameters:
rhs- the callback list to set. May not benull.- Returns:
EChange
-
set
Clear all elements and add only the passed value.- Parameters:
aCallback- The callback to be used. May not benull.- Returns:
EChange
-
add
Add a callback.- Parameters:
aCallback- May not benull.- Returns:
EChange
-
addAll
Add an array of elements to this collection.- Parameters:
aCallbacks- The elements to be added. May be null.- Returns:
EChange
-
removeObject
Remove the specified callback- Parameters:
aCallback- May benull.- Returns:
EChange
-
removeAll
Remove all callbacks- Returns:
EChange
-
getAllCallbacks
- Specified by:
getAllCallbacksin interfaceICallbackList<CALLBACKTYPE extends ICallback>- Returns:
- A list of all callbacks. Never
nulland only containing non-nullelements.
-
getCallbackAtIndex
Description copied from interface:ICallbackListGet the callback at the specified index.- Specified by:
getCallbackAtIndexin interfaceICallbackList<CALLBACKTYPE extends ICallback>- Parameters:
nIndex- The index to be retrieved. Should be ≥ 0.- Returns:
nullif the provided index is invalid.
-
size
-
isEmpty
public boolean isEmpty() -
getClone
- Specified by:
getClonein interfaceICloneable<CALLBACKTYPE extends ICallback>- Returns:
- A 100% deep-copy of the implementing class.
-
iterator
- Specified by:
iteratorin interfaceIterable<CALLBACKTYPE extends ICallback>
-
forEach
- Specified by:
forEachin interfaceIterable<CALLBACKTYPE extends ICallback>
-
forEachBreakable
@Nonnull public EContinue forEachBreakable(@Nonnull Function<? super CALLBACKTYPE, EContinue> aFunction) Description copied from interface:ICommonsIterableA special version ofIterable.forEach(Consumer)that can break iteration if a certain requirement is fulfilled.- Specified by:
forEachBreakablein interfaceICommonsIterable<CALLBACKTYPE extends ICallback>- Parameters:
aFunction- The consumer to be invoked. May not benull.- Returns:
EContinue.BREAKif iteration was stopped,EContinue.CONTINUEotherwise.
-
toString
-