Interface Traversal<S,​E>

    • Method Detail

      • asAdmin

        default Traversal.Admin<S,​E> asAdmin()
        Get access to administrative methods of the traversal via its accompanying Traversal.Admin.
        Returns:
        the admin of this traversal
      • tryNext

        default Optional<E> tryNext()
        Return an Optional of the next E object in the traversal. If the traversal is empty, then an Optional.empty() is returned.
        Returns:
        an optional of the next object in the traversal
      • next

        default List<E> next​(int amount)
        Get the next n-number of results from the traversal. If the traversal has less than n-results, then only that number of results are returned.
        Parameters:
        amount - the number of results to get
        Returns:
        the n-results in a List
      • toList

        default List<E> toList()
        Put all the results into an ArrayList.
        Returns:
        the results in a list
      • toSet

        default Set<E> toSet()
        Put all the results into a HashSet.
        Returns:
        the results in a set
      • toBulkSet

        default BulkSet<E> toBulkSet()
        Put all the results into a BulkSet. This can reduce both time and space when aggregating results by ensuring a weighted set.
        Returns:
        the results in a bulk set
      • toStream

        default Stream<E> toStream()
        Return the traversal as a Stream.
        Returns:
        the traversal as a stream.
      • fill

        default <C extends Collection<E>> C fill​(C collection)
        Add all the results of the traversal to the provided collection.
        Parameters:
        collection - the collection to fill
        Returns:
        the collection now filled
      • iterate

        default <A,​B> Traversal<A,​B> iterate()
        Iterate all the Traverser instances in the traversal. What is returned is the empty traversal. It is assumed that what is desired from the computation is are the sideEffects yielded by the traversal.
        Returns:
        the fully drained traversal
      • none

        default Traversal<S,​E> none()
        Filter all traversers in the traversal. This step has narrow use cases and is primarily intended for use as a signal to remote servers that iterate() was called. While it may be directly used, it is often a sign that a traversal should be re-written in another form.
        Returns:
        the updated traversal with respective NoneStep.
      • forEachRemaining

        default <E2> void forEachRemaining​(Class<E2> endType,
                                           Consumer<E2> consumer)
        A traversal can be rewritten such that its defined end type E may yield objects of a different type. This helper method allows for the casting of the output to the known the type.
        Type Parameters:
        E2 - the known output type of the traversal
        Parameters:
        endType - the true output type of the traversal
        consumer - a Consumer to process each output
      • notifyClose

        default void notifyClose()
        Gets a callback from close() for additional operations specific to the Traversal implementation. A good implementation will use close() to release resources in steps and this method to release resources specific to the Traversal implementations.