Package tools.common

Class StreamUtils

java.lang.Object
tools.common.StreamUtils

public abstract class StreamUtils extends Object
Static methods
Author:
Pavel Ponec
  • Method Details

    • rows

      @NotNull public @NotNull Stream<String> rows(@NotNull @NotNull String text)
      Read a String. A line separator can be modifed in the result
      Returns:
      The result must be closed.
    • rowsOfUrl

      public static Stream<String> rowsOfUrl(@NotNull @NotNull URL url) throws IOException
      Returns a stream of lines form URL resource
      Parameters:
      url - An URL link to a resource
      Returns:
      The customer is responsible for closing the stream. During closing, an IllegalStateException may occur due to an IOException.
      Throws:
      IOException
    • toStream

      public static <T> Stream<T> toStream(@NotNull @NotNull Iterator<T> iterator)
      Convert an interator to a Stream
      Type Parameters:
      T - An item type
      Parameters:
      iterator - Source iterator
      Returns:
    • toStream

      public static <T> Stream<T> toStream(@NotNull @NotNull Iterator<T> iterator, boolean parallel)
      Convert an interator to a Stream
      Type Parameters:
      T - An item type
      Parameters:
      iterator - Source iterator
      parallel - Parrallell processing is enabled
      Returns:
    • collectToDequeue

      @NotNull public static <T> @NotNull Collector<T,?,ArrayDeque<T>> collectToDequeue()
      A stream collecetor to a ArrayDeque type
    • toJoinable

      @NotNull public static <D, R> @NotNull Joinable<D,R> toJoinable(@NotNull @NotNull Function<D,R> fce)
      Create a joinable function

      Usage

      Assert.java:54
        Function<Person, String> nameProvider = Joinable
           .of (Person::getBoss)
           .add(Person::getBoss)
           .add(Person::getName);
        String superBossName = nameProvider.apply(getPerson());
       
      Type Parameters:
      D - Domain value
      R - Result value
      Parameters:
      fce - An original function
      Returns:
      The new object type of Function