Package com.topjohnwu.superuser
Class CallbackList<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
com.topjohnwu.superuser.CallbackList<E>
- All Implemented Interfaces:
Iterable<E>,Collection<E>,List<E>
An
AbstractList that calls 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 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.
-
Field Summary
FieldsFields inherited from class java.util.AbstractList
modCount -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedonAddElement(Object)runs on the main thread; no backing list.protectedCallbackList(Executor executor) onAddElement(Object)runs with the executor; no backing list.protectedCallbackList(Executor executor, List<E> base) onAddElement(Object)runs with the executor; sets a backing list.protectedCallbackList(List<E> base) onAddElement(Object)runs on the main thread; sets a backing list. -
Method Summary
Methods inherited from class java.util.AbstractList
add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subListMethods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
-
Field Details
-
mBase
-
mExecutor
-
-
Constructor Details
-
CallbackList
protected CallbackList()onAddElement(Object)runs on the main thread; no backing list. -
CallbackList
onAddElement(Object)runs on the main thread; sets a backing list. -
CallbackList
onAddElement(Object)runs with the executor; no backing list. -
CallbackList
onAddElement(Object)runs with the executor; sets a backing list.
-
-
Method Details
-
onAddElement
The callback when a new element is added.This method will be called after
addis 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.
-
get
-
set
-
add
-
remove
-
size
public int size()- Specified by:
sizein interfaceCollection<E>- Specified by:
sizein interfaceList<E>- Specified by:
sizein classAbstractCollection<E>- See Also:
-