Class ConverterListIterator<I,O>
- java.lang.Object
-
- com.globalmentor.collections.iterators.ConverterIterator<I,O>
-
- com.globalmentor.collections.iterators.ConverterListIterator<I,O>
-
- Type Parameters:
I
- The input type.O
- The output type.
- All Implemented Interfaces:
java.util.Iterator<O>
,java.util.ListIterator<O>
public class ConverterListIterator<I,O> extends ConverterIterator<I,O> implements java.util.ListIterator<O>
A list iterator that returns its objects converted using aConverter
.This implementation does not support adding or setting elements.
- Author:
- Garret Wilson
- See Also:
Converter
-
-
Constructor Summary
Constructors Constructor Description ConverterListIterator(java.util.ListIterator<I> iterator, Converter<I,O> converter)
Iterator and converter constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(O e)
protected java.util.ListIterator<I>
getIterator()
This version returns the iterator as aListIterator
.boolean
hasNext()
boolean
hasPrevious()
O
next()
int
nextIndex()
O
previous()
int
previousIndex()
void
set(O e)
-
Methods inherited from class com.globalmentor.collections.iterators.ConverterIterator
getConverter, remove
-
-
-
-
Constructor Detail
-
ConverterListIterator
public ConverterListIterator(java.util.ListIterator<I> iterator, Converter<I,O> converter)
Iterator and converter constructor.- Parameters:
iterator
- The iterator of source objects.converter
- The conversor to be used on the iterable.- Throws:
java.lang.NullPointerException
- of if the given iterator and/or converter isnull
.
-
-
Method Detail
-
getIterator
protected java.util.ListIterator<I> getIterator()
This version returns the iterator as aListIterator
.- Overrides:
getIterator
in classConverterIterator<I,O>
- Returns:
- The iterator this class decorates.
-
hasNext
public boolean hasNext()
-
next
public O next()
This implementation converts the next object before returning it.
This implementation converts the next object before returning it.
- Specified by:
next
in interfacejava.util.Iterator<I>
- Specified by:
next
in interfacejava.util.ListIterator<I>
- Overrides:
next
in classConverterIterator<I,O>
- See Also:
Converter.convert(Object)
-
hasPrevious
public boolean hasPrevious()
- Specified by:
hasPrevious
in interfacejava.util.ListIterator<I>
-
previous
public O previous()
This implementation converts the previous object before returning it.
- Specified by:
previous
in interfacejava.util.ListIterator<I>
- See Also:
Converter.convert(Object)
-
nextIndex
public int nextIndex()
- Specified by:
nextIndex
in interfacejava.util.ListIterator<I>
-
previousIndex
public int previousIndex()
- Specified by:
previousIndex
in interfacejava.util.ListIterator<I>
-
set
public void set(O e)
This implementation throws an
UnsupportedOperationException
.- Specified by:
set
in interfacejava.util.ListIterator<I>
-
-