
com.lumiomedical.flow.Pipe Maven / Gradle / Ivy
package com.lumiomedical.flow;
import com.lumiomedical.flow.actor.generator.Generator;
import com.lumiomedical.flow.actor.loader.Loader;
import com.lumiomedical.flow.actor.transformer.BiTransformer;
import com.lumiomedical.flow.actor.transformer.Transformer;
import com.lumiomedical.flow.interruption.Interruption;
import com.lumiomedical.flow.io.output.Recipient;
import com.lumiomedical.flow.node.SimpleNode;
import com.lumiomedical.flow.stream.StreamGenerator;
import java.util.function.Function;
import java.util.function.Predicate;
/**
* Pipes are a point of passage in a DAG.
* They accept an input from upstream which they can alter and pass downstream.
*
* @author Pierre Lecerf ([email protected])
* Created on 2020/02/28
*/
public class Pipe extends SimpleNode> implements FlowIn, FlowOut
{
/**
*
* @param actor
*/
public Pipe(Transformer actor)
{
super(actor);
}
@Override
public Pipe into(Transformer transformer)
{
var pipe = new Pipe<>(transformer);
this.bind(pipe);
return pipe;
}
@Override
public Sink into(Loader loader)
{
var sink = new Sink<>(loader);
this.bind(sink);
return sink;
}
@Override
public Join join(FlowOut input, BiTransformer transformer)
{
return new Join<>(this, input, transformer);
}
@Override
public StreamGenerator stream(Function> generatorSupplier)
{
var pipe = new StreamGenerator<>(generatorSupplier);
this.bind(pipe);
return pipe;
}
/**
*
* @param loader
* @return
*/
public Pipe driftSink(Loader loader)
{
this.into(loader);
return this;
}
@Override
public Recipient collect(String name)
{
Recipient recipient = new Recipient<>(name);
this.bind(recipient);
return recipient;
}
/**
*
* @param name
* @return
*/
public Pipe sample(String name)
{
this.collect(name);
return this;
}
/**
*
* @return
*/
public Pipe interrupt()
{
return this.into(new Interruption<>());
}
/**
*
* @param predicate
* @return
*/
public Pipe interruptIf(Predicate predicate)
{
return this.into(new Interruption<>(predicate));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy