collection.add("Item 2");
collection.add("Item 3");
collection.add("Item 4");
collection.add("Item 5");
IteratorTemplate template = new IteratorTemplate(collection);
ElementGenerator finder = template.findAll(new Constraint() {
public boolean test(Object o) {
return ((String)o).startsWith("Item 4");
}
});
finder.run(new Block() {
protected void handle(Object o) {
assertEquals("Item 4", o);
}
});
finder = template.findAll(new Constraint() {
public boolean test(Object o) {
return ((String)o).startsWith("Element");
}
});
finder.run(new Block() {