Consider an object that extracts object values from a source on a "pull" basis, until a special value (e.g., null
) is encountered.
In Java
, the API could be something like
public interface ValueExtractor<T> {
public T extractNext();
}
Operationally, this is an Iterator
but it only has a (sort of) "next()" method and is not a Reader
since it does not read from the source byte-by-byte. It also resembles a database cursor in the sense that it "scrolls" over all data values (records), until they are exhausted.
Is there a design pattern other than "iterator" for this use case?
What would be the best name to call such a simple object?
Aucun commentaire:
Enregistrer un commentaire