-
- All Implemented Interfaces:
-
java.lang.Iterable,java.util.Collection,java.util.List
public abstract class CallbackList<E> extends AbstractList<E>
An AbstractList that calls
{@code onAddElement}when a new element is added to the list.To simplify the API of Shell, both STDOUT and STDERR will output to Lists. This class is useful if you want to trigger a callback every time Shell outputs a new line.
The
{@code CallbackList}itself does not have a data store. If you need one, you can provide a base List, and this class will delegate its calls to it.
-
-
Method Summary
Modifier and Type Method Description abstract voidonAddElement(E e)The callback when a new element is added. Eget(int i)Eset(int i, E s)voidadd(int i, E s)Eremove(int i)intsize()-
Methods inherited from class java.util.AbstractList
add, add, addAll, clear, equals, get, hashCode, indexOf, iterator, lastIndexOf, listIterator, remove, set, subList -
Methods inherited from class java.util.AbstractCollection
contains, containsAll, isEmpty, remove, removeAll, retainAll, size, toArray, toArray, toString -
Methods inherited from class java.util.Collection
parallelStream, removeIf, spliterator, stream -
Methods inherited from class java.lang.Iterable
forEach, iterator, spliterator -
Methods inherited from class java.util.List
copyOf, of, replaceAll, sort -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
onAddElement
abstract void onAddElement(E e)
The callback when a new element is added.
This method will be called after
{@code add}is called.Which thread it runs on depends on which constructor is used to construct the instance.- Parameters:
e- the new element added to the list.
-
size
int size()
-
-
-
-