Created
September 19, 2012 02:00
-
-
Save kinow/3747204 to your computer and use it in GitHub Desktop.
commons-functor trunk code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.commons.functor.generator.GenerateWhile; | |
import org.apache.commons.functor.generator.util.IntegerRange; | |
public class T { | |
public static void main(String[] args) { | |
UnaryPredicate<Integer> lessThanTwo = new UnaryPredicate<Integer>() { | |
public boolean test(Integer obj) { | |
return obj != null && obj < 2; | |
} | |
}; | |
UnaryProcedure<Integer> printMe = new UnaryProcedure<Integer>() { | |
public void run(Integer obj) { | |
System.out.print(obj + " "); | |
} | |
}; | |
IntegerRange integerRange = new IntegerRange(0, 10); | |
GenerateWhile<Integer> generateWhile = new GenerateWhile<Integer>(integerRange, lessThanTwo); | |
generateWhile.run(printMe); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment