Top Description Fields Constructors Methods
org.apache.commons.collections4.iterators

public Class SingletonListIterator<E>

extends Object
implements ResettableListIterator<E>
Class Inheritance
All Implemented Interfaces
org.apache.commons.collections4.ResettableListIterator, org.apache.commons.collections4.OrderedIterator, java.util.Iterator, org.apache.commons.collections4.ResettableIterator, java.util.ListIterator
Imports
java.util.NoSuchElementException, org.apache.commons.collections4.ResettableListIterator

SingletonIterator is an java.util.ListIterator over a single object instance.
Since
2.1

Field Summary

Modifier and TypeField and Description
private boolean
private boolean
private E
private boolean

Constructor Summary

AccessConstructor and Description
public
SingletonListIterator(final E
the single object to return from the iterator
object
)

Constructs a new SingletonListIterator.

Method Summary

Modifier and TypeMethod and Description
public void
add(final E
the object to add
obj
)

Implements java.util.ListIterator.add.

Add always throws UnsupportedOperationException.
public boolean

Returns:

true if the single object hasn't been returned yet
hasNext
()

Implements java.util.ListIterator.hasNext, java.util.Iterator.hasNext.

Is another object available from the iterator?
public boolean

Returns:

true if the single object has been returned
hasPrevious
()

Implements java.util.ListIterator.hasPrevious, org.apache.commons.collections4.OrderedIterator.hasPrevious.

Is a previous object available from the iterator?
public E

Returns:

the single object
next
()

Implements java.util.ListIterator.next, java.util.Iterator.next.

Get the next object from the iterator.
public int

Returns:

0 or 1 depending on current state.
nextIndex
()

Implements java.util.ListIterator.nextIndex.

Returns the index of the element that would be returned by a subsequent call to next.
public E

Returns:

the single object
previous
()

Implements java.util.ListIterator.previous, org.apache.commons.collections4.OrderedIterator.previous.

Get the previous object from the iterator.
public int

Returns:

0 or -1 depending on current state.
previousIndex
()

Implements java.util.ListIterator.previousIndex.

Returns the index of the element that would be returned by a subsequent call to previous.
public void
remove()

Overrides default java.util.Iterator.remove.

Implements java.util.ListIterator.remove.

Remove the object from this iterator.
public void
reset()

Implements org.apache.commons.collections4.ResettableIterator.reset.

Reset the iterator back to the start.
public void
set(final E
the object to set
obj
)

Implements java.util.ListIterator.set.

Set sets the value of the singleton.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

beforeFirstback to summary
private boolean beforeFirst
nextCalledback to summary
private boolean nextCalled
objectback to summary
private E object
removedback to summary
private boolean removed

Constructor Detail

SingletonListIteratorback to summary
public SingletonListIterator(final E object)

Constructs a new SingletonListIterator.

Parameters
object:E

the single object to return from the iterator

Method Detail

addback to summary
public void add(final E obj)

Implements java.util.ListIterator.add.

Add always throws UnsupportedOperationException.

Parameters
obj:E

the object to add

Annotations
@Override
Exceptions
UnsupportedOperationException:
always
hasNextback to summary
public boolean hasNext()

Implements java.util.ListIterator.hasNext, java.util.Iterator.hasNext.

Is another object available from the iterator?

This returns true if the single object hasn't been returned yet.

Returns:boolean

true if the single object hasn't been returned yet

Annotations
@Override
hasPreviousback to summary
public boolean hasPrevious()

Implements java.util.ListIterator.hasPrevious, org.apache.commons.collections4.OrderedIterator.hasPrevious.

Is a previous object available from the iterator?

This returns true if the single object has been returned.

Returns:boolean

true if the single object has been returned

Annotations
@Override
nextback to summary
public E next()

Implements java.util.ListIterator.next, java.util.Iterator.next.

Get the next object from the iterator.

This returns the single object if it hasn't been returned yet.

Returns:E

the single object

Annotations
@Override
Exceptions
NoSuchElementException:
if the single object has already been returned
nextIndexback to summary
public int nextIndex()

Implements java.util.ListIterator.nextIndex.

Returns the index of the element that would be returned by a subsequent call to next.

Returns:int

0 or 1 depending on current state.

Annotations
@Override
previousback to summary
public E previous()

Implements java.util.ListIterator.previous, org.apache.commons.collections4.OrderedIterator.previous.

Get the previous object from the iterator.

This returns the single object if it has been returned.

Returns:E

the single object

Annotations
@Override
Exceptions
NoSuchElementException:
if the single object has not already been returned
previousIndexback to summary
public int previousIndex()

Implements java.util.ListIterator.previousIndex.

Returns the index of the element that would be returned by a subsequent call to previous. A return value of -1 indicates that the iterator is currently at the start.

Returns:int

0 or -1 depending on current state.

Annotations
@Override
removeback to summary
public void remove()

Overrides default java.util.Iterator.remove.

Implements java.util.ListIterator.remove.

Remove the object from this iterator.

Annotations
@Override
Exceptions
IllegalStateException:
if the next or previous method has not yet been called, or the remove method has already been called after the last call to next or previous.
resetback to summary
public void reset()

Implements org.apache.commons.collections4.ResettableIterator.reset.

Reset the iterator back to the start.

Annotations
@Override
setback to summary
public void set(final E obj)

Implements java.util.ListIterator.set.

Set sets the value of the singleton.

Parameters
obj:E

the object to set

Annotations
@Override
Exceptions
IllegalStateException:
if next has not been called or the object has been removed