org.apache.commons.functor.example.kata.two
Class EiffelStyleLoop

java.lang.Object
  extended by org.apache.commons.functor.example.kata.two.EiffelStyleLoop
All Implemented Interfaces:
Runnable, Functor, NullaryFunctor, Procedure

public class EiffelStyleLoop
extends Object
implements Procedure

Supports an Eiffel style loop construct.

 new EiffelStyleLoop()
   .from(new Procedure() { public void run() {} }) // init code
   .invariant(new Predicate() { public boolean test() {} }) // invariants
   .variant(new Procedure() { public Object evaluate() {} }) // diminishing comparable value
   // or
   // .variant(new Predicate() { public boolean test() {} }) // more invariants
   .until(new Predicate() { public boolean test() {} }) // terminating condition
   .loop(new Procedure() { public void run() {} }) // the acutal loop
   .run();
 
Note that new EiffelStyleLoop().run() executes just fine. You only need to set the parts of the loop you want to use.

Version:
$Revision: 666191 $ $Date: 2008-06-10 18:43:53 +0200 (Tue, 10 Jun 2008) $
Author:
Rodney Waldhoff

Constructor Summary
EiffelStyleLoop()
           
 
Method Summary
 EiffelStyleLoop from(Procedure procedure)
           
 EiffelStyleLoop invariant(Predicate predicate)
           
 EiffelStyleLoop loop(Procedure procedure)
           
 void run()
           
 EiffelStyleLoop until(Predicate predicate)
           
 EiffelStyleLoop variant(Function function)
           
 EiffelStyleLoop variant(Predicate predicate)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.commons.functor.Functor
equals, hashCode, toString
 

Constructor Detail

EiffelStyleLoop

public EiffelStyleLoop()
Method Detail

from

public EiffelStyleLoop from(Procedure procedure)

invariant

public EiffelStyleLoop invariant(Predicate predicate)

variant

public EiffelStyleLoop variant(Predicate predicate)

variant

public EiffelStyleLoop variant(Function function)

until

public EiffelStyleLoop until(Predicate predicate)

loop

public EiffelStyleLoop loop(Procedure procedure)

run

public void run()
Specified by:
run in interface Runnable
Specified by:
run in interface Procedure


Copyright © 2003-2011 The Apache Software Foundation. All Rights Reserved.