@Test public void testAdapter(){ Source<String> name = new Source<String>("foo"); Adapter<String, Integer> charCount = new Adapter<String, Integer>(name, new Functor<String, Integer>(){ @Override public Integer evaluate(String value) { return value.length(); } } ); Assert.assertEquals(charCount.output().currentValue(), (Integer)3); name.supply("foobar"); Assert.assertEquals(charCount.output().currentValue(), (Integer)6); }
public Adapter(Source<IN> in, final Functor<IN, OUT> functor){ output = new Source<OUT>(functor.evaluate(in.currentValue())); in.addReceiver(new Receiver<IN>() { @Override public void receive(IN value) { output.supply(functor.evaluate(value)); } }); }
Adapter { public Adapter(Source<IN> in, final Functor<IN, OUT> functor){ output = new Source<OUT>(functor.evaluate(in.currentValue())); in.addReceiver(new Receiver<IN>() { @Override public void receive(IN value) { output.supply(functor.evaluate(value)); } }); } }
Adapter { public Adapter(Source<IN> in, final Functor<IN, OUT> functor){ output = new Source<OUT>(functor.evaluate(in.currentValue())); in.addReceiver(new Receiver<IN>() { @Override public void receive(IN value) { output.supply(functor.evaluate(value)); } }); } Adapter(Source<IN> in, final Functor<IN, OUT> functor); }
Adapter { public Adapter(Source<IN> in, final Functor<IN, OUT> functor){ output = new Source<OUT>(functor.evaluate(in.currentValue())); in.addReceiver(new Receiver<IN>() { @Override public void receive(IN value) { output.supply(functor.evaluate(value)); } }); } Adapter(Source<IN> in, final Functor<IN, OUT> functor); Signal<OUT> output(); }
Adapter { public Adapter(Source<IN> in, final Functor<IN, OUT> functor){ output = new Source<OUT>(functor.evaluate(in.currentValue())); in.addReceiver(new Receiver<IN>() { @Override public void receive(IN value) { output.supply(functor.evaluate(value)); } }); } Adapter(Source<IN> in, final Functor<IN, OUT> functor); Signal<OUT> output();  }