test_class.file: code/src/test/java/com/googlecode/cqengine/resultset/common/IteratorCachingResultSetTest.java
test_class.identifier: IteratorCachingResultSetTest
test_case.body: @Test
      @SuppressWarnings("unchecked")
      public void testIteratorCaching() {
          ResultSet<Car> backingResultSet = mock(ResultSet.class);
          when(backingResultSet.iterator()).thenReturn(mock(Iterator.class), mock(Iterator.class), mock(Iterator.class), mock(Iterator.class), mock(Iterator.class), mock(Iterator.class), mock(Iterator.class));
          IteratorCachingResultSet<Car> iteratorCachingResultSet = new IteratorCachingResultSet<Car>(backingResultSet);
  
          Iterator<Car> i1 = iteratorCachingResultSet.iterator();
          Iterator<Car> i2 = iteratorCachingResultSet.iterator();
          assertSame(i1, i2);
  
          i2.hasNext();
          i2.hasNext();
          Iterator<Car> i3 = iteratorCachingResultSet.iterator();
          assertSame(i1, i3);
  
          i3.next();
          Iterator<Car> i4 = iteratorCachingResultSet.iterator();
          assertNotSame(i3, i4);
  
          i4.remove();
          Iterator<Car> i5 = iteratorCachingResultSet.iterator();
          assertNotSame(i4, i5);
  
          i5.hasNext();
          i5.hasNext();
          Iterator<Car> i6 = iteratorCachingResultSet.iterator();
          assertSame(i5, i6);
  
          iteratorCachingResultSet.isEmpty();
          iteratorCachingResultSet.isNotEmpty();
          Iterator<Car> i7 = iteratorCachingResultSet.iterator();
          assertSame(i6, i7);
      }
test_case.class_method_signature: IteratorCachingResultSetTest.testIteratorCaching()
test_case.full_signature: @Test @SuppressWarnings("unchecked") public void testIteratorCaching()
test_case.identifier: testIteratorCaching
test_case.invocations: mock thenReturn when iterator mock mock mock mock mock mock mock iterator iterator assertSame hasNext hasNext iterator assertSame next iterator assertNotSame remove iterator assertNotSame hasNext hasNext iterator assertSame isEmpty isNotEmpty iterator assertSame
test_case.modifiers: @Test @SuppressWarnings("unchecked") public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testIteratorCaching()
focal_class.declarator: cachedIterator = null
focal_class.original_string: Iterator<O> cachedIterator = null;
focal_class.type: Iterator<O>
focal_class.var_name: cachedIterator
focal_class.file: code/src/main/java/com/googlecode/cqengine/resultset/common/IteratorCachingResultSet.java
focal_class.identifier: IteratorCachingResultSet
focal_class.class_method_signature: IteratorCachingResultSet.IteratorCachingResultSet(ResultSet<O> backingResultSet)
focal_class.full_signature: public  IteratorCachingResultSet(ResultSet<O> backingResultSet)
focal_class.identifier: IteratorCachingResultSet
focal_class.modifiers: public
focal_class.parameters: (ResultSet<O> backingResultSet)
focal_class.signature:  IteratorCachingResultSet(ResultSet<O> backingResultSet)
focal_class.class_method_signature: IteratorCachingResultSet.iterator()
focal_class.full_signature: @Override public Iterator<O> iterator()
focal_class.identifier: iterator
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Iterator<O>
focal_class.signature: Iterator<O> iterator()
focal_class.superclass: extends WrappedResultSet<O>
focal_method.body: @Override
      public Iterator<O> iterator() {
          if (cachedIterator != null) {
              return cachedIterator;
          }
          final Iterator<O> backingIterator = wrappedResultSet.iterator();
          Iterator<O> wrappingIterator = new Iterator<O>() {
  
              @Override
              public boolean hasNext() {
                  return backingIterator.hasNext();
              }
  
              @Override
              public O next() {
                  cachedIterator = null;
                  return backingIterator.next();
              }
  
              @Override
              public void remove() {
                  cachedIterator = null;
                  backingIterator.remove();
              }
          };
          this.cachedIterator = wrappingIterator;
          return wrappingIterator;
      }
focal_method.class_method_signature: IteratorCachingResultSet.iterator()
focal_method.full_signature: @Override public Iterator<O> iterator()
focal_method.identifier: iterator
focal_method.invocations: iterator hasNext next remove
focal_method.modifiers: @Override public
focal_method.parameters: ()
focal_method.return: Iterator<O>
focal_method.signature: Iterator<O> iterator()