Class EmptyListIterator<T>

java.lang.Object
com.cedarsoftware.io.util.EmptyListIterator<T>
All Implemented Interfaces:
Iterator<T>, ListIterator<T>

public class EmptyListIterator<T> extends Object implements ListIterator<T>
Author:
John DeRegnaucourt ([email protected])
Copyright (c) Cedar Software LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

License

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(T e)
    Throws UnsupportedOperationException because this operation is not supported by the empty list iterator.
    boolean
    Returns false as there are no elements in any direction.
    boolean
    Returns false as there are no elements in any direction.
    Throws NoSuchElementException because there are no elements to return.
    int
    Always returns 0 because there are no elements.
    Throws NoSuchElementException because there are no elements to return.
    int
    Always returns -1 because there are no elements.
    void
    Throws UnsupportedOperationException because this operation is not supported by the empty list iterator.
    void
    set(T e)
    Throws UnsupportedOperationException because this operation is not supported by the empty list iterator.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.util.Iterator

    forEachRemaining
  • Constructor Details

    • EmptyListIterator

      public EmptyListIterator()
  • Method Details

    • hasNext

      public boolean hasNext()
      Returns false as there are no elements in any direction.
      Specified by:
      hasNext in interface Iterator<T>
      Specified by:
      hasNext in interface ListIterator<T>
    • next

      public T next()
      Throws NoSuchElementException because there are no elements to return.
      Specified by:
      next in interface Iterator<T>
      Specified by:
      next in interface ListIterator<T>
    • hasPrevious

      public boolean hasPrevious()
      Returns false as there are no elements in any direction.
      Specified by:
      hasPrevious in interface ListIterator<T>
    • previous

      public T previous()
      Throws NoSuchElementException because there are no elements to return.
      Specified by:
      previous in interface ListIterator<T>
    • remove

      public void remove()
      Throws UnsupportedOperationException because this operation is not supported by the empty list iterator.
      Specified by:
      remove in interface Iterator<T>
      Specified by:
      remove in interface ListIterator<T>
    • set

      public void set(T e)
      Throws UnsupportedOperationException because this operation is not supported by the empty list iterator.
      Specified by:
      set in interface ListIterator<T>
    • add

      public void add(T e)
      Throws UnsupportedOperationException because this operation is not supported by the empty list iterator.
      Specified by:
      add in interface ListIterator<T>
    • nextIndex

      public int nextIndex()
      Always returns 0 because there are no elements.
      Specified by:
      nextIndex in interface ListIterator<T>
    • previousIndex

      public int previousIndex()
      Always returns -1 because there are no elements.
      Specified by:
      previousIndex in interface ListIterator<T>