Class Data

java.lang.Object
org.praxislive.code.userapi.Data

public class Data extends Object
Support for creating data pipes to work with data of any type. All data chains are driven by a Data.Sink. Input and output ports of type Data.In and Data.Out can be created. Only pipes and ports of the identical generic type can be connected together.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Input port pipe.
    static class 
    Output port pipe.
    static interface 
    A data holder used to wrap data of type T to be passed around a Pipe graph.
    static class 
    The base type of pipes that can be connected to form processing graphs.
    static class 
    Data sink to drive pipe graph.
  • Method Summary

    Modifier and Type
    Method
    Description
    static final <T> Data.Pipe<T>
    apply(Function<? super T,? extends T> function)
    Create a pipe that applies the function to every type T passing through.
    static final <T> Data.Pipe<T>
    combine(BiFunction<T,List<T>,? extends T> combiner)
    Create a pipe that applies the combiner function to every type T passing through.
    static final <T> Data.Pipe<T>
    combineWith(BiConsumer<T,List<T>> combiner)
    Create a pipe that applies the combiner function to every type T passing through.
    static final <T> Data.Pipe<T>
    Create a pipe that applies no additional processing to every type T passing through.
    static final <T> Data.Pipe<T>
    link(Data.Pipe<T>... pipes)
    Link provided Data.Pipes together.
    static final <T> Data.Pipe<T>
    supply(Supplier<? extends T> supplier)
    Create a pipe that supplies new instances of type T.
    static final <T> Data.Pipe<T>
    with(Consumer<? super T> consumer)
    Create a pipe that applies the consumer to every type T passing through.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • apply

      public static final <T> Data.Pipe<T> apply(Function<? super T,? extends T> function)
      Create a pipe that applies the function to every type T passing through. The function may return the supplied input or another instance of type T.
      Type Parameters:
      T - type of data
      Parameters:
      function - function to apply to data
      Returns:
      pipe
    • combine

      public static final <T> Data.Pipe<T> combine(BiFunction<T,List<T>,? extends T> combiner)
      Create a pipe that applies the combiner function to every type T passing through. The function may return the supplied input or another instance of type T. The first argument of the function corresponds to the first source of the pipe, if there is one, else a cleared T. The second argument is a list of T corresponding to any additional sources.
      Type Parameters:
      T - type of data
      Parameters:
      combiner - combination function to apply to data
      Returns:
      pipe
    • combineWith

      public static final <T> Data.Pipe<T> combineWith(BiConsumer<T,List<T>> combiner)
      Create a pipe that applies the combiner function to every type T passing through. The first argument of the function corresponds to the first source of the pipe, if there is one, else a cleared T. The second argument is a list of T corresponding to any additional sources. The function should combine data into the first argument T, which assumes that T is mutable. To combine into a different instance of T, use combine(java.util.function.BiFunction).
      Type Parameters:
      T - type of data
      Parameters:
      combiner - combination function to apply to data
      Returns:
      pipe
    • identity

      public static final <T> Data.Pipe<T> identity()
      Create a pipe that applies no additional processing to every type T passing through. The pipe will use the clear and accumulate functions defined on the sink.

      This pipe is useful where you need a placeholder element, a clear source, or to combine sources using the default accumulation.

      Type Parameters:
      T - type of data
      Returns:
      pipe
    • link

      @SafeVarargs public static final <T> Data.Pipe<T> link(Data.Pipe<T>... pipes)
      Link provided Data.Pipes together.
      Type Parameters:
      T - common type of data supported by pipes
      Parameters:
      pipes - pipes to connect
      Returns:
      last pipe, for convenience
    • supply

      public static final <T> Data.Pipe<T> supply(Supplier<? extends T> supplier)
      Create a pipe that supplies new instances of type T. This pipe does not support sources.
      Type Parameters:
      T - type of data to supply
      Parameters:
      supplier - function to supply instance of T
      Returns:
      pipe
    • with

      public static final <T> Data.Pipe<T> with(Consumer<? super T> consumer)
      Create a pipe that applies the consumer to every type T passing through. This assumes that either the data type is mutable or that its contents will be used but not changed. To map the type to a different instance of T, use apply(java.util.function.Function).
      Type Parameters:
      T - type of data
      Parameters:
      consumer - consumer function to apply to data of type T
      Returns:
      pipe