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 com.google.common.annotations.GwtCompatible;
020import java.util.Collections;
021import java.util.EnumSet;
022import java.util.Iterator;
023import java.util.ListIterator;
024import java.util.Set;
025
026/**
027 * A method supported by implementations of the {@link Iterator} or {@link ListIterator} interface.
028 *
029 * <p>This enum is GWT compatible.
030 *
031 * @author Chris Povirk
032 */
033@GwtCompatible
034public enum IteratorFeature {
035  /** Support for {@link Iterator#remove()}. */
036  SUPPORTS_REMOVE,
037  /**
038   * Support for {@link ListIterator#add(Object)}; ignored for plain {@link Iterator}
039   * implementations.
040   */
041  SUPPORTS_ADD,
042  /**
043   * Support for {@link ListIterator#set(Object)}; ignored for plain {@link Iterator}
044   * implementations.
045   */
046  SUPPORTS_SET;
047
048  /**
049   * A set containing none of the optional features of the {@link Iterator} or {@link ListIterator}
050   * interfaces.
051   */
052  public static final Set<IteratorFeature> UNMODIFIABLE = Collections.emptySet();
053
054  /**
055   * A set containing all of the optional features of the {@link Iterator} and {@link ListIterator}
056   * interfaces.
057   */
058  public static final Set<IteratorFeature> MODIFIABLE =
059      Collections.unmodifiableSet(EnumSet.allOf(IteratorFeature.class));
060}