com.avaje.ebean.QueryEachConsumer Maven / Gradle / Ivy
package com.avaje.ebean;
/**
* Used to process a query result one bean at a time via a callback to this
* visitor.
*
* If you wish to stop further processing return false from the accept method.
*
*
* Unlike findList() and findSet() using a QueryResultVisitor does not require
* all the beans in the query result to be held in memory at once. This makes
* QueryResultVisitor useful for processing large queries.
*
*
* {@code
*
* Query query = server.find(Customer.class)
* .where().eq("status", Status.NEW)
* .order().asc("id");
*
* query.findEach((Customer customer) -> {
*
* // do something with customer
* System.out.println("-- visit " + customer);
* });
*
* }
*
* @param
* the type of entity bean being queried.
*/
public interface QueryEachConsumer {
/**
* Process the bean.
*
* @param bean
* the entity bean to process
*/
void accept(T bean);
}