net.fortytwo.flow
Class Switch<T>

java.lang.Object
  extended by net.fortytwo.flow.Switch<T>
Type Parameters:
T - the type of data being passed
All Implemented Interfaces:
Sink<T>

public class Switch<T>
extends Object
implements Sink<T>

A modal pipeline which passes data alternately to one of two downstream sinks

Author:
Joshua Shinavier (http://fortytwo.net)

Constructor Summary
Switch(Sink<T> left, Sink<T> right)
          Constructs a new switch over the given sinks
 
Method Summary
 void flip()
          Toggles between the two downstream sinks.
 void put(T t)
          Receives the next data item and passes it to the appropriate downstream sink.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Switch

public Switch(Sink<T> left,
              Sink<T> right)
Constructs a new switch over the given sinks

Parameters:
left - one of two downstream sinks
right - the other of two downstream sinks
Method Detail

put

public void put(T t)
         throws RippleException
Receives the next data item and passes it to the appropriate downstream sink.

Specified by:
put in interface Sink<T>
Parameters:
t - the data item being passed
Throws:
RippleException - if a data handling error occurs

flip

public void flip()
Toggles between the two downstream sinks. When this method is called, one sink becomes inactive (idle) while the other becomes active (ready to receive data).



Copyright © 2007-2014. All Rights Reserved.