Package 

Class CallbackList

  • 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 void onAddElement(E e) The callback when a new element is added.
      E get(int i)
      E set(int i, E s)
      void add(int i, E s)
      E remove(int i)
      int size()
      • 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.
      • set

         E set(int i, E s)
      • add

         void add(int i, E s)