Neo4j Enterprise

org.neo4j.graphdb
Interface ResourceIterable<T>

Type Parameters:
T - the type of values returned through the iterators.
All Superinterfaces:
Iterable<T>
All Known Subinterfaces:
IndexHits<T>

public interface ResourceIterable<T>
extends Iterable<T>

Iterable whose iterators have associated resources that must be managed. This interface is similar to { @link Iterable } but adds additional functionality to ensure that resources can be released. If you intend to exhaust the returned iterators, you can use conventional code aas you would with a normal Iterable:

 ResourceIterable<Object> iterable;
 for ( Object item : iterable )
 {
     ...
 }
 
However, if your code might not exhaust the iterator, you should ensure that you call close on the iterator, using a finally block or try-with-resources.
 ResourceIterable<Object> iterable;
 ResourceIterator<Object> iterator = iterable.iterator();
 try
 {
     while ( iterator.hasNext() )
     {
         Object item = iterator.next();
         if ( ... )
         {
             return item; // iterator may not be exhausted.
         }
     }
 }
 finally
 {
     iterator.close();
 }
 

See Also:
ResourceIterator

Method Summary
 ResourceIterator<T> iterator()
          Returns an iterator with associated resources that must be managed.
 

Method Detail

iterator

ResourceIterator<T> iterator()
Returns an iterator with associated resources that must be managed. Don't forget to either exhaust the returned iterator or call the close method on it.

Specified by:
iterator in interface Iterable<T>

Neo4j Enterprise

Copyright © 2002-2013 The Neo4j Graph Database Project. All Rights Reserved.