Java ListIterator Usage emptyIterator()

Here you can find the source of emptyIterator()

Description

empty Iterator

License

Open Source License

Declaration

@SuppressWarnings("unchecked")
    public static final <T> ListIterator<T> emptyIterator() 

Method Source Code

//package com.java2s;
/*//w  ww.  jav a 2  s .  c o  m
 * Copyright 2008-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at:
 *
 *     http://aws.amazon.com/apache2.0/
 *
 * or in the "license" file accompanying this file. This file 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.
 */

import java.util.ListIterator;
import java.util.NoSuchElementException;

public class Main {
    public static final ListIterator<?> EMPTY_ITERATOR = new ListIterator() {
        public boolean hasNext() {
            return false;
        }

        public boolean hasPrevious() {
            return false;
        }

        public Object next() {
            throw new NoSuchElementException();
        }

        public Object previous() {
            throw new NoSuchElementException();
        }

        public void remove() {
            throw new IllegalStateException();
        }

        public int nextIndex() {
            return 0;
        }

        public int previousIndex() {
            return -1;
        }

        public void add(Object o) {
            throw new UnsupportedOperationException();
        }

        public void set(Object o) {
            throw new UnsupportedOperationException();
        }
    };

    @SuppressWarnings("unchecked")
    public static final <T> ListIterator<T> emptyIterator() {
        return (ListIterator<T>) EMPTY_ITERATOR;
    }
}

Related

  1. castIterator(final Iterator iterator)
  2. clearNulls(Collection col)
  3. containsUsingListIteratorNext(List list, Integer value)
  4. createCommaSeparatedListOfFullTypeNames(ListIterator strIt)
  5. differingDigits(final int lhs, final int rhs, final int base)
  6. filterStringList(final String prefix, final String infix, final String suffix, final List list)
  7. findFirstIterator(List list, int fromIndex, int toIndex, T value, Comparator comparator)
  8. findObject(Object item, ListIterator iter)
  9. findPrevious(ListIterator iter)