public class SingletonIterator extends Object implements Iterator, ResettableIterator
SingletonIterator
is an Iterator
over a single
object instance.Constructor and Description |
---|
SingletonIterator(Object object)
Constructs a new
SingletonIterator where remove
is a permitted operation. |
SingletonIterator(Object object,
boolean removeAllowed)
Constructs a new
SingletonIterator optionally choosing if
remove is a permitted operation. |
public SingletonIterator(Object object)
SingletonIterator
where remove
is a permitted operation.object
- the single object to return from the iteratorpublic SingletonIterator(Object object, boolean removeAllowed)
SingletonIterator
optionally choosing if
remove
is a permitted operation.object
- the single object to return from the iteratorremoveAllowed
- true if remove is allowedpublic boolean hasNext()
This returns true if the single object hasn't been returned yet.
public Object next()
This returns the single object if it hasn't been returned yet.
next
in interface Iterator
NoSuchElementException
- if the single object has already
been returnedpublic void remove()
remove
in interface Iterator
IllegalStateException
- if the next method has not
yet been called, or the remove method has already
been called after the last call to the next
method.UnsupportedOperationException
- if remove is not supportedpublic void reset()
reset
in interface ResettableIterator
Copyright © 2001–2015 The Apache Software Foundation. All rights reserved.