Package io.microsphere.collection
Class DelegatingIterator<E>
- java.lang.Object
-
- io.microsphere.collection.DelegatingIterator<E>
-
- Type Parameters:
E- the type of elements returned by this iterator
- All Implemented Interfaces:
DelegatingWrapper,Wrapper,java.util.Iterator<E>
- Direct Known Subclasses:
EmptyIterator
public class DelegatingIterator<E> extends java.lang.Object implements java.util.Iterator<E>, DelegatingWrapper
A delegating implementation of theIteratorinterface that forwards all method calls to a delegate iterator. This class is useful when you want to wrap an existing iterator and potentially override some of its behavior.Example Usage
List<String> list = Arrays.asList("a", "b", "c"); Iterator<String> iterator = new DelegatingIterator<>(list.iterator()); while (iterator.hasNext()) { System.out.println(iterator.next()); }- Author:
- Mercy
- See Also:
Iterator
-
-
Constructor Summary
Constructors Constructor Description DelegatingIterator(java.util.Iterator<E> delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)voidforEachRemaining(java.util.function.Consumer<? super E> action)java.lang.ObjectgetDelegate()Get the delegateinthashCode()booleanhasNext()Enext()voidremove()java.lang.StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.microsphere.lang.DelegatingWrapper
isWrapperFor, unwrap
-
-
-
-
Constructor Detail
-
DelegatingIterator
public DelegatingIterator(java.util.Iterator<E> delegate)
-
-
Method Detail
-
hasNext
public final boolean hasNext()
- Specified by:
hasNextin interfacejava.util.Iterator<E>
-
remove
public final void remove()
- Specified by:
removein interfacejava.util.Iterator<E>
-
forEachRemaining
public final void forEachRemaining(java.util.function.Consumer<? super E> action)
- Specified by:
forEachRemainingin interfacejava.util.Iterator<E>
-
getDelegate
public final java.lang.Object getDelegate()
Description copied from interface:DelegatingWrapperGet the delegate- Specified by:
getDelegatein interfaceDelegatingWrapper- Returns:
- the delegate
-
hashCode
public final int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public final boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public final java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-