Class PositionListBase<T,P extends IPositionHolder<T,P>>

java.lang.Object
com.vladsch.flexmark.experimental.util.collection.iteration.PositionListBase<T,P>
Type Parameters:
T - type of position
P - type of position holder
All Implemented Interfaces:
IPositionListener, IPositionUpdater<T,P>, IPreviewPositionListener, Iterable<P>
Direct Known Subclasses:
PositionList

public abstract class PositionListBase<T,P extends IPositionHolder<T,P>> extends Object implements Iterable<P>, IPositionUpdater<T,P>
Iterator for list positions allowing to iterate over current elements while inserting and deleting elements relative to current position

elements inserted at current position or at current + 1 position will skipped in the iteration allowing adding new elements which will not be part of the iteration

  • Field Details

  • Constructor Details

    • PositionListBase

      public PositionListBase(@NotNull @NotNull List<T> list, @NotNull @NotNull PositionFactory<T,P> factory)
  • Method Details

    • getListeners

      @TestOnly public int getListeners()
    • getMaxListeners

      @TestOnly public int getMaxListeners()
    • getPreviewListeners

      @TestOnly public int getPreviewListeners()
    • addPositionListener

      public void addPositionListener(@NotNull @NotNull IPositionListener listener)
      Add list edit listener for notifications of mods to the list
      Specified by:
      addPositionListener in interface IPositionUpdater<T,P extends IPositionHolder<T,P>>
      Parameters:
      listener - listener
    • removePositionListener

      public void removePositionListener(@NotNull @NotNull IPositionListener listener)
      Remove list edit listener

      NOTE: removal is optional. Only weak refs are kept for the listener

      Specified by:
      removePositionListener in interface IPositionUpdater<T,P extends IPositionHolder<T,P>>
      Parameters:
      listener - listener
    • iterator

      @NotNull public @NotNull Iterator<P> iterator()
      Specified by:
      iterator in interface Iterable<T>
    • reversedIterator

      @NotNull public @NotNull Iterator<P> reversedIterator()
    • reversed

      @NotNull public @NotNull Iterable<P> reversed()
    • iterator

      @NotNull public @NotNull Iterator<P> iterator(@NotNull P position)
      Specified by:
      iterator in interface IPositionUpdater<T,P extends IPositionHolder<T,P>>
    • getList

      @NotNull public @NotNull List<T> getList()
      Specified by:
      getList in interface IPositionUpdater<T,P extends IPositionHolder<T,P>>
    • isEmpty

      public boolean isEmpty()
    • isNotEmpty

      public boolean isNotEmpty()
    • get

      public T get(int index)
    • getOrNull

      public T getOrNull(int index)
    • getOrNull

      public <S extends T> S getOrNull(int index, Class<S> elementClass)
    • openFrame

      public Object openFrame()
    • getListParentId

      @NotNull public @NotNull String getListParentId()
    • closeFrame

      public void closeFrame(Object frameId)
    • throwIllegalStateWithOpenFrameTrace

      private void throwIllegalStateWithOpenFrameTrace(@Nullable @Nullable StringBuilder out, PositionListBase.FrameLevel frame)
    • getPosition

      public P getPosition(int index, @NotNull @NotNull PositionAnchor anchor)
      Specified by:
      getPosition in interface IPositionUpdater<T,P extends IPositionHolder<T,P>>
    • unframe

      public void unframe(P position)
      Specified by:
      unframe in interface IPositionUpdater<T,P extends IPositionHolder<T,P>>
    • getFirst

      public P getFirst()
    • getLast

      public P getLast()
    • getEnd

      public P getEnd()
    • clear

      public void clear()
      Specified by:
      clear in interface IPositionUpdater<T,P extends IPositionHolder<T,P>>
    • inserted

      public void inserted(int index, int count)
      Description copied from interface: IPositionListener
      insert Notification
      Specified by:
      inserted in interface IPositionListener
      Parameters:
      index - at which insert was performed, list contents and size at this point are already updated
      count - of elements inserted
    • deleted

      public void deleted(int index, int count)
      Description copied from interface: IPositionListener
      delete Notification
      Specified by:
      deleted in interface IPositionListener
      Parameters:
      index - at which delete was performed, list contents and size at this point are already updated
      count - of elements deleted
    • deleting

      public void deleting(int index, int count)
      Description copied from interface: IPreviewPositionListener
      before delete Notification
      Specified by:
      deleting in interface IPreviewPositionListener
      Parameters:
      index - at which delete will be performed, list contents and size at this point have not changed
      count - of elements deleted
    • changing

      public Object changing(int index, Object value)
      Description copied from interface: IPreviewPositionListener
      Before set Notification

      NOTE: the returned class should be the same or a subclass of original object's class

      Specified by:
      changing in interface IPreviewPositionListener
      Parameters:
      index - at which set is being performed, list contents and size at this point are not updated
      value - new value for the element
      Returns:
      value to use for setting the element
    • changed

      public void changed(int index, Object oldValue, Object newValue)
      Description copied from interface: IPreviewPositionListener
      After set Notification

      NOTE: the returned class should be the same or a subclass of original object's class

      Specified by:
      changed in interface IPreviewPositionListener
      Parameters:
      index - at which set is being performed, list contents and size at this point are already updated
      oldValue - value at index before setting
      newValue - value at index before setting
    • set

      public T set(int index, T value)
    • remove

      public T remove(int index)
    • remove

      public void remove(int startIndex, int endIndex)
    • add

      public boolean add(T element)
    • add

      public boolean add(int index, T element)
    • addAll

      public boolean addAll(@NotNull @NotNull PositionListBase<T,P> other)
    • addAll

      public boolean addAll(int index, @NotNull @NotNull PositionListBase<T,P> other)
    • addAll

      public boolean addAll(@NotNull @NotNull Collection<? extends T> elements)
    • addAll

      public boolean addAll(int index, @NotNull @NotNull Collection<? extends T> elements)
    • size

      public int size()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object