- 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
Data.In<T>
Input port pipe.static class
Data.Out<T>
Input port pipe.static interface
Data.Packet<T>
A data holder used to wrap data of type T to be passed around a Pipe graph.static class
Data.Pipe<T>
The base type of pipes that can be connected to form processing graphs.static class
Data.Sink<T>
Data sink to drive pipe graph.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <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 <T> Data.Pipe<T>
link(Data.Pipe<T>... pipes)
Link provided Data.Pipes together.static <T> Data.Pipe<T>
supply(Supplier<? extends T> supplier)
Create a pipe that supplies new instances of type T.static <T> Data.Pipe<T>
with(Consumer<? super T> consumer)
Create a pipe that applies the consumer to every type T passing through.
-
-
-
Method Detail
-
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
-
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().- Type Parameters:
T
- type of data- Parameters:
consumer
- consumer function to apply to data of type T- Returns:
- pipe
-
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
-
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
-
-