@@ -0,0 +1,2566 @@
+/*%0A * Copyright 2010-2012 Luca Garulli (l.garulli--at--orientechnologies.com)%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage com.orientechnologies.orient.core.iterator;%0A%0Aimport java.util.Iterator;%0Aimport java.util.NoSuchElementException;%0A%0Aimport com.orientechnologies.common.util.OResettable;%0Aimport com.orientechnologies.common.util.OSizeable;%0A%0A/**%0A * Iterator that created wrapped objects during browsing.%0A * %0A * @author Luca Garulli (l.garulli--at--orientechnologies.com)%0A */%0Apublic abstract class OLazyWrapperIterator%3CT%3E implements Iterator%3CT%3E, Iterable%3CT%3E, OResettable, OSizeable %7B%0A  protected final Iterator%3C?%3E iterator;%0A  protected T                 nextElement;%0A  protected final int         size;       // -1 = UNKNOWN%0A%0A  public OLazyWrapperIterator(final Iterator%3C?%3E iterator) %7B%0A    this.iterator = iterator;%0A    this.size = -1;%0A  %7D%0A%0A  public OLazyWrapperIterator(final Iterator%3C?%3E iterator, final int iSize) %7B%0A    this.iterator = iterator;%0A    this.size = iSize;%0A  %7D%0A%0A  public abstract boolean filter(T iObject);%0A%0A  public abstract T createWrapper(Object iObject);%0A%0A  @Override%0A  public Iterator%3CT%3E iterator() %7B%0A    reset();%0A    return this;%0A  %7D%0A%0A  public int size() %7B%0A    if (size %3E -1)%0A      return size;%0A%0A    if (iterator instanceof OSizeable)%0A      return ((OSizeable) iterator).size();%0A%0A    return 0;%0A  %7D%0A%0A  @Override%0A  public void reset() %7B%0A    if (iterator instanceof OResettable)%0A      // RESET IT FOR MULTIPLE ITERATIONS%0A      ((OResettable) iterator).reset();%0A    nextElement = null;%0A  %7D%0A%0A  @Override%0A  public boolean hasNext() %7B%0A    while (nextElement == null && iterator.hasNext()) %7B%0A      nextElement = createWrapper(iterator.next());%0A      if (nextElement != null && !filter(nextElement))%0A        nextElement = null;%0A    %7D%0A%0A    return nextElement != null;%0A  %7D%0A%0A  @Override%0A  public T next() %7B%0A    if (hasNext())%0A      try %7B%0A        return nextElement;%0A      %7D finally %7B%0A        nextElement = null;%0A      %7D%0A%0A    throw new NoSuchElementException();%0A  %7D%0A%0A  @Override%0A  public void remove() %7B%0A    iterator.remove();%0A  %7D%0A%7D%0A

Revert deletion of OLazyWrapperIterator