Class StreamOps

java.lang.Object
org.apache.jena.atlas.lib.StreamOps

public class StreamOps extends Object
Collect some stream operations into one place. Sometimes, the function form reads better.
See Also:
  • Constructor Details

    • StreamOps

      public StreamOps()
  • Method Details

    • stream

      public static <X> Stream<X> stream(Iterator<X> iter)
      Iterator to Stream. Call to Iter.asStream(java.util.Iterator<T>).
    • toList

      public static <X> List<X> toList(Stream<X> stream)
      Stream to List
    • toSet

      public static <X> Set<X> toSet(Stream<X> stream)
      Stream to Set
    • first

      public static <X> X first(Stream<X> stream)
      First element or null
    • element

      public static <X> X element(Collection<X> collection)
      An element from a Collection
    • print

      public static <X> Stream<X> print(Stream<X> stream)
      Debug : print stream. This operation prints the whole stream at the point it is used, and then returns a new stream of the same elements.
    • print

      public static <X> Stream<X> print(PrintStream out, Stream<X> stream)
    • print

      public static <X> Stream<X> print(PrintStream out, String leader, Stream<X> stream)
    • debug

      public static <X> Stream<X> debug(Stream<X> stream)
      Print immediate, noting empty streams