Class SingleElementIterator<E>

java.lang.Object
io.sf.carte.util.SingleElementIterator<E>
Type Parameters:
E - the element type.
All Implemented Interfaces:
Iterator<E>

public class SingleElementIterator<E> extends Object implements Iterator<E>
Iterates an immutable collection composed by a single element.
  • Constructor Details

    • SingleElementIterator

      public SingleElementIterator(E element)
      Construct a new iterator with the given element.
      Parameters:
      element - the element.
      Throws:
      NullPointerException - if the element is null.
  • Method Details

    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<E>
    • next

      public E next()
      Specified by:
      next in interface Iterator<E>