public class SingletonListIterator extends Object implements ListIterator, ResettableListIterator
SingletonIterator
is an ListIterator
over a single
object instance.Constructor and Description |
---|
SingletonListIterator(Object object)
Constructs a new
SingletonListIterator . |
Modifier and Type | Method and Description |
---|---|
void |
add(Object obj)
Add always throws
UnsupportedOperationException . |
boolean |
hasNext()
Is another object available from the iterator?
|
boolean |
hasPrevious()
Is a previous object available from the iterator?
|
Object |
next()
Get the next object from the iterator.
|
int |
nextIndex()
Returns the index of the element that would be returned by a subsequent
call to next.
|
Object |
previous()
Get the previous object from the iterator.
|
int |
previousIndex()
Returns the index of the element that would be returned by a subsequent
call to previous.
|
void |
remove()
Remove the object from this iterator.
|
void |
reset()
Reset the iterator back to the start.
|
void |
set(Object obj)
Set sets the value of the singleton.
|
public SingletonListIterator(Object object)
SingletonListIterator
.object
- the single object to return from the iteratorpublic boolean hasNext()
This returns true if the single object hasn't been returned yet.
hasNext
in interface Iterator
hasNext
in interface ListIterator
public boolean hasPrevious()
This returns true if the single object has been returned.
hasPrevious
in interface ListIterator
public int nextIndex()
nextIndex
in interface ListIterator
public int previousIndex()
previousIndex
in interface ListIterator
public Object next()
This returns the single object if it hasn't been returned yet.
next
in interface Iterator
next
in interface ListIterator
NoSuchElementException
- if the single object has already
been returnedpublic Object previous()
This returns the single object if it has been returned.
previous
in interface ListIterator
NoSuchElementException
- if the single object has not already
been returnedpublic void remove()
remove
in interface Iterator
remove
in interface ListIterator
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.public void add(Object obj)
UnsupportedOperationException
.add
in interface ListIterator
UnsupportedOperationException
- alwayspublic void set(Object obj)
set
in interface ListIterator
obj
- the object to setIllegalStateException
- if next has not been called
or the object has been removedpublic void reset()
reset
in interface ResettableIterator
reset
in interface ResettableListIterator
Copyright © 2001–2015 The Apache Software Foundation. All rights reserved.