001/*
002 * Copyright (C) 2008 The Guava Authors
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package com.google.common.collect.testing;
018
019import static java.util.Arrays.asList;
020import static java.util.Collections.emptySet;
021import static java.util.Collections.unmodifiableSet;
022
023import com.google.common.annotations.GwtCompatible;
024import java.util.Iterator;
025import java.util.LinkedHashSet;
026import java.util.ListIterator;
027import java.util.Set;
028
029/**
030 * A method supported by implementations of the {@link Iterator} or {@link ListIterator} interface.
031 *
032 * <p>This enum is GWT compatible.
033 *
034 * @author Chris Povirk
035 */
036@GwtCompatible
037public enum IteratorFeature {
038  /** Support for {@link Iterator#remove()}. */
039  SUPPORTS_REMOVE,
040  /**
041   * Support for {@link ListIterator#add(Object)}; ignored for plain {@link Iterator}
042   * implementations.
043   */
044  SUPPORTS_ADD,
045  /**
046   * Support for {@link ListIterator#set(Object)}; ignored for plain {@link Iterator}
047   * implementations.
048   */
049  SUPPORTS_SET;
050
051  /**
052   * A set containing none of the optional features of the {@link Iterator} or {@link ListIterator}
053   * interfaces.
054   */
055  public static final Set<IteratorFeature> UNMODIFIABLE = emptySet();
056
057  /**
058   * A set containing all of the optional features of the {@link Iterator} and {@link ListIterator}
059   * interfaces.
060   */
061  public static final Set<IteratorFeature> MODIFIABLE =
062      unmodifiableSet(new LinkedHashSet<>(asList(values())));
063}