Interface ListNode

All Superinterfaces:
CommentableNode<List<Node<?>>>, Node<List<Node<?>>>

public sealed interface ListNode extends CommentableNode<List<Node<?>>>
A Node implementation that represents a List of Nodes.
  • Field Details

    • IMPLEMENTATION_CLASS

      @Internal static final Class<? extends ListNode> IMPLEMENTATION_CLASS
      An implementation Class of this interface.
  • Method Details

    • create

      @NotNull static @NotNull ListNode create()
      Creates a new ListNode.
      Returns:
      a new ListNode
    • create

      @NotNull static @NotNull ListNode create(int initialCapacity)
      Creates a new ListNode.
      Parameters:
      initialCapacity - the initial capacity of the list
      Returns:
      a new ListNode
    • create

      @NotNull static @NotNull ListNode create(@NotNull @NotNull Collection<?> collection)
      Creates a new ListNode with values in the given Collection.
      Parameters:
      collection - a Collection to add elements to the new ListNode
      Returns:
      a new ListNode with values in the given Collection
    • empty

      @NotNull static @NotNull @Unmodifiable ListNode empty()
      Gets a ListNode that is always empty.

      The returning ListNode cannot be modified using methods like add(Object).

      Returns:
      a ListNode that is always empty
    • value

      @NotNull @NotNull @UnmodifiableView List<Node<?>> value()
      Gets a List that this ListNode has.

      The returning List cannot be modified, but the elements in the list may be changed by other codes.

      Specified by:
      value in interface Node<List<Node<?>>>
      Returns:
      a List that this ListNode has
    • asList

      @NotNull <T> @NotNull @Unmodifiable List<T> asList(@NotNull @NotNull Class<? extends T> elementClass)
      Gets a List containing elements of the specified Class.

      The returning List is immutable.

      The list only contain elements such that Class.isInstance(java.lang.Object) returns true. Other elements are ignored.

      Type Parameters:
      T - a type of the class
      Parameters:
      elementClass - a class to cast elements
      Returns:
      a List containing elements of the specified Class
    • stream

      @NotNull @NotNull Stream<Node<?>> stream()
      Creates a Stream from an internal list.
      Returns:
      a Stream from an internal list
    • add

      void add(@NotNull @NotNull Object value)
      Adds a new object to this ListNode.
      Parameters:
      value - a new object
    • addAll

      void addAll(@NotNull @NotNull Collection<?> collection)
      Adds new objects in the given Collection to this ListNode.
      Parameters:
      collection - a Collection that includes new objects to add
    • addList

      @NotNull @NotNull ListNode addList()
      Adds a new ListNode to this ListNode.
      Returns:
      a created ListNode
    • addList

      @NotNull @NotNull ListNode addList(int initialCapacity)
      Adds a new ListNode to this ListNode.
      Parameters:
      initialCapacity - the initial capacity of the list
      Returns:
      a created ListNode
    • addMap

      @NotNull @NotNull MapNode addMap()
      Adds a new MapNode to this ListNode.
      Returns:
      a created MapNode
    • remove

      void remove(@NotNull @NotNull Object value)
      Removes an object from this ListNode.
      Parameters:
      value - an object to remove from this ListNode
    • removeIf

      void removeIf(@NotNull @NotNull Predicate<Node<?>> predicate)
      Removes the elements from this ListNode that satisfy the given predicate.
      Parameters:
      predicate - a predicate which returns true for elements to be removed
    • clear

      void clear()
      Clears this ListNode.
    • copy

      @Contract("-> new") @NotNull @NotNull ListNode copy()
      Copies this ListNode.

      The elements in this ListNode will also be copied using Node.fromObject(Object).

      Returns:
      a copied ListNode
    • asView

      @Contract("-> new") @NotNull @NotNull @UnmodifiableView ListNode asView()
      Gets a view of this ListNode.

      The returning ListNode cannot be modified, but this ListNode can still be modified, so the elements may be changed by other codes using this instance.

      Returns:
      a view of this ListNode