Class RestrictedCollections.RestrictedListIterator

    • Field Detail

      • m_iter

        protected ListIterator m_iter
        The underlying ListIterator.
      • m_clz

        protected Class m_clz
        The class of Objects stored in the ListIterator.
    • Constructor Detail

      • RestrictedListIterator

        public RestrictedListIterator​(ListIterator iter,
                                      Class clz)
        Constructor.
        Parameters:
        iter - the underlying ListIterator
        clz - the class of objects that may be stored in the ListIterator
    • Method Detail

      • hasNext

        public boolean hasNext()
        Returns true if this list iterator has more elements when traversing the list in the forward direction. Obeys the general contract of ListIterator.hasNext.
        Specified by:
        hasNext in interface Iterator
        Specified by:
        hasNext in interface ListIterator
        Returns:
        true if the list iterator has more elements when traversing the list in the forward direction
      • next

        public Object next()
        Returns the next element in the list. Obeys the general contract of ListIterator.next.
        Specified by:
        next in interface Iterator
        Specified by:
        next in interface ListIterator
        Returns:
        the next element in the list
      • hasPrevious

        public boolean hasPrevious()
        Returns true if this list iterator has more elements when traversing the list in the reverse direction. Obeys the general contract of ListIterator.hasPrevious.
        Specified by:
        hasPrevious in interface ListIterator
        Returns:
        true if the list iterator has more elements when traversing the list in the reverse direction
      • previous

        public Object previous()
        Returns the previous element in the list. Obeys the general contract of ListIterator.previous.
        Specified by:
        previous in interface ListIterator
        Returns:
        the previous element in the list
        Throws:
        NoSuchElementException - if the iteration has no previous element
      • nextIndex

        public int nextIndex()
        Returns the index of the element that would be returned by a subsequent call to next. Obeys the general contract of ListIterator.nextIndex.
        Specified by:
        nextIndex in interface ListIterator
        Returns:
        the index of the element that would be returned by a subsequent call to next, or list size if list iterator is at end of list
      • previousIndex

        public int previousIndex()
        Returns the index of the element that would be returned by a subsequent call to previous. Obeys the general contract of ListIterator.previousIndex.
        Specified by:
        previousIndex in interface ListIterator
        Returns:
        the index of the element that would be returned by a subsequent call to previous, or -1 if list iterator is at beginning of list
      • remove

        public void remove()
        Removes from the list the last element that was returned by next or previous. Obeys the general contract of ListIterator.remove.
        Specified by:
        remove in interface Iterator
        Specified by:
        remove in interface ListIterator
      • set

        public void set​(Object o)
        Replaces the last element returned by next or previous with the specified element. Obeys the general contract of ListIterator.set.
        Specified by:
        set in interface ListIterator
        Parameters:
        o - the element with which to replace the last element returned by next or previous
        Throws:
        ClassCastException - if the class of the specified element prevents it from being added to this list
      • add

        public void add​(Object o)
        Inserts the specified element into the list. Obeys the general contract of ListIterator.add.
        Specified by:
        add in interface ListIterator
        Parameters:
        o - the element to insert
        Throws:
        ClassCastException - if the class of the specified element prevents it from being added to this ListIterator
      • checkObject

        protected void checkObject​(Object o)
        Check the passed object to verify that it passes the restriction of this ListIterator.
        Parameters:
        o - the Object to check
        Throws:
        ClassCastException - if the class of the passed Object prevents it from being stored in this ListIterator