Class AbstractPath<E>

java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
com.valhalla.sdk.api.pathing.AbstractPath<E>
Type Parameters:
E - path-node type
All Implemented Interfaces:
Iterable<E>, Collection<E>, List<E>, SequencedCollection<E>
Direct Known Subclasses:
LocalPath

public abstract class AbstractPath<E> extends AbstractList<E>
Mutable ordered path with reversible traversal direction.
  • Constructor Details

    • AbstractPath

      protected AbstractPath()
      Creates an empty forward path.
    • AbstractPath

      protected AbstractPath(Collection<? extends E> values)
      Creates a forward path from an optional collection.
      Parameters:
      values - initial nodes; null creates an empty path
  • Method Details

    • get

      public E get(int index)
      Specified by:
      get in interface List<E>
      Specified by:
      get in class AbstractList<E>
    • size

      public int size()
      Specified by:
      size in interface Collection<E>
      Specified by:
      size in interface List<E>
      Specified by:
      size in class AbstractCollection<E>
    • set

      public E set(int index, E value)
      Specified by:
      set in interface List<E>
      Overrides:
      set in class AbstractList<E>
    • add

      public void add(int index, E value)
      Specified by:
      add in interface List<E>
      Overrides:
      add in class AbstractList<E>
    • remove

      public E remove(int index)
      Specified by:
      remove in interface List<E>
      Overrides:
      remove in class AbstractList<E>
    • addAll

      @SafeVarargs public final boolean addAll(E... values)
      Appends non-null nodes in argument order.
      Parameters:
      values - nodes to append; null leaves the path unchanged
      Returns:
      true when at least one node was appended
    • addToFront

      public void addToFront(E value)
      Inserts a node at the front.
      Parameters:
      value - non-null node inserted at index zero
    • first

      public E first()
      Returns the first node.
      Returns:
      first node, or null when empty
    • last

      public E last()
      Returns the final node.
      Returns:
      final node, or null when empty
    • path

      public List<E> path()
      Copies this path into an immutable list.
      Returns:
      immutable snapshot of the ordered nodes
    • direction

      public PathDirection direction()
      Returns the traversal direction.
      Returns:
      current traversal direction
    • setDirection

      public void setDirection(PathDirection value)
      Sets the traversal direction without reordering nodes.
      Parameters:
      value - non-null traversal direction
    • reverse

      public void reverse()
      Reverses node order and toggles the traversal direction label.
    • next

      public abstract E next()
      Returns the next node suitable for the current player location.
      Returns:
      next node, or null when no candidate exists
    • walk

      public abstract boolean walk()
      Advances toward the next suitable path node.
      Returns:
      true when progress is already healthy or a walk action was accepted