Package org.springframework.rules.closure

Examples of org.springframework.rules.closure.ElementGenerator


   * @param it the iterator
   * @param constraint the constraint
   * @return The objects that match, or a empty collection if none match
   */
  public Collection findAll(Iterator it, Constraint constraint) {
    ElementGenerator finder = new IteratorTemplate(it).findAll(constraint);
    final Collection results = new ArrayList();
    finder.run(new Block() {
      protected void handle(Object element) {
        results.add(element);
      }
    });
    return results;
View Full Code Here


    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() {
      protected void handle(Object o) {
        fail("Should not be called");
      }
    });
  }
View Full Code Here

TOP

Related Classes of org.springframework.rules.closure.ElementGenerator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.