加载中...
The Wayback Machine - https://sup1a9wrlpyh5li9ro.vcoronado.top/web/20090218034157/http://developer.android.com:80/reference/java/util/EnumSet.html
public abstract class

EnumSet

extends AbstractSet<E>
implements Serializable Cloneable
java.lang.Object
   ↳ java.util.AbstractCollection<E>
     ↳ java.util.AbstractSet<E>
       ↳ java.util.EnumSet<E extends java.lang.Enum<E>>

Summary

Public Methods
static <E extends Enum<E>> EnumSet<E> allOf(Class<E> elementType)
Creates an enum set.
EnumSet<E> clone()
Creates a new enum set with the same elements as those contained in this enum set.
static <E extends Enum<E>> EnumSet<E> complementOf(EnumSet<E> s)
Creates an enum set.
static <E extends Enum<E>> EnumSet<E> copyOf(EnumSet<E> s)
Creates an enum set.
static <E extends Enum<E>> EnumSet<E> copyOf(Collection<E> c)
Creates an enum set.
static <E extends Enum<E>> EnumSet<E> noneOf(Class<E> elementType)
Creates an empty enum set.
static <E extends Enum<E>> EnumSet<E> of(E start, E... others)
Creates a new enum set, containing only the specified elements.
static <E extends Enum<E>> EnumSet<E> of(E e)
Creates a new enum set, containing only the specified element.
static <E extends Enum<E>> EnumSet<E> of(E e1, E e2, E e3, E e4, E e5)
Creates a new enum set, containing only the specified elements.
static <E extends Enum<E>> EnumSet<E> of(E e1, E e2, E e3)
Creates a new enum set, containing only the specified elements.
static <E extends Enum<E>> EnumSet<E> of(E e1, E e2, E e3, E e4)
Creates a new enum set, containing only the specified elements.
static <E extends Enum<E>> EnumSet<E> of(E e1, E e2)
Creates a new enum set, containing only the specified elements.
static <E extends Enum<E>> EnumSet<E> range(E start, E end)
Creates an enum set containing all the elements within the range defined by start and end (inclusive).
[Expand]
Inherited Methods
From class java.util.AbstractSet
From class java.util.AbstractCollection
From class java.lang.Object
From interface java.lang.Iterable
From interface java.util.Collection
From interface java.util.Set

Public Methods

public static EnumSet<E> allOf (Class<E> elementType)

Creates an enum set. Element is contained in this enum set if and only if it is a member of the specified element type.

Parameters
elementType the class object for the elements contained
Returns
  • an enum set with elements solely from the specified element type
Throws
NullPointerException if the specified elementType is null

public EnumSet<E> clone ()

Creates a new enum set with the same elements as those contained in this enum set.

Returns
  • a new enum set with the same elements as those contained in this enum set

public static EnumSet<E> complementOf (EnumSet<E> s)

Creates an enum set. All the contained elements complement those from the specified enum set.

Parameters
s the specified enum set
Returns
  • an enum set with all the elements complement those from the specified enum set
Throws
NullPointerException if the specified enum set is null

public static EnumSet<E> copyOf (EnumSet<E> s)

Creates an enum set. All the contained elements are of type Class, and the contained elements are the same as those contained in s.

Parameters
s the enum set from which to copy
Returns
  • an enum set with all the elements from the specified enum set
Throws
NullPointerException if the specified enum set is null

public static EnumSet<E> copyOf (Collection<E> c)

Creates an enum set. The contained elements are the same as those contained in collection c. If c is an enum set, invoking this method is the same as invoking copyOf(EnumSet).

Parameters
c the collection from which to copy
Returns
  • an enum set with all the elements from the specified collection
Throws
IllegalArgumentException if c is not an enum set and contains no elements at all
NullPointerException if the specified collection is null

public static EnumSet<E> noneOf (Class<E> elementType)

Creates an empty enum set. The permitted elements are of type Class.

Parameters
elementType the class object for the elements contained
Returns
  • an empty enum set, with permitted elements of the specified elementType
Throws
NullPointerException if the specified elementType is null

public static EnumSet<E> of (E start, E... others)

Creates a new enum set, containing only the specified elements. It receives arbitrary number of elements, and runs slower than those only receive fixed number of elements.

Parameters
start the first initially contained element
others the other initially contained elements
Returns
  • an enum set containing the specified elements
Throws
NullPointerException if any of the specified elements is null

public static EnumSet<E> of (E e)

Creates a new enum set, containing only the specified element. There are six overloadings of the method. They accept from one to five elements respectively. The sixth one receives arbitrary number of elements, and runs slower than those only receive fixed number of elements.

Parameters
e the initially contained element
Returns
  • an enum set containing the specified element
Throws
NullPointerException if the specified element is null

public static EnumSet<E> of (E e1, E e2, E e3, E e4, E e5)

Creates a new enum set, containing only the specified elements. There are six overloadings of the method. They accept from one to five elements respectively. The sixth one receives arbitrary number of elements, and runs slower than those only receive fixed number of elements.

Parameters
e1 the initially contained element
e2 another initially contained element
e3 another initially contained element
e4 another initially contained element
e5 another initially contained element
Returns
  • an enum set containing the specified elements
Throws
NullPointerException if any of the specified elements is null

public static EnumSet<E> of (E e1, E e2, E e3)

Creates a new enum set, containing only the specified elements. There are six overloadings of the method. They accept from one to five elements respectively. The sixth one receives arbitrary number of elements, and runs slower than those only receive fixed number of elements.

Parameters
e1 the initially contained element
e2 another initially contained element
e3 another initially contained element
Returns
  • an enum set containing the specified elements
Throws
NullPointerException if any of the specified elements is null

public static EnumSet<E> of (E e1, E e2, E e3, E e4)

Creates a new enum set, containing only the specified elements. There are six overloadings of the method. They accept from one to five elements respectively. The sixth one receives arbitrary number of elements, and runs slower than those only receive fixed number of elements.

Parameters
e1 the initially contained element
e2 another initially contained element
e3 another initially contained element
e4 another initially contained element
Returns
  • an enum set containing the specified elements
Throws
NullPointerException if any of the specified elements is null

public static EnumSet<E> of (E e1, E e2)

Creates a new enum set, containing only the specified elements. There are six overloadings of the method. They accept from one to five elements respectively. The sixth one receives arbitrary number of elements, and runs slower than those only receive fixed number of elements.

Parameters
e1 the initially contained element
e2 another initially contained element
Returns
  • an enum set containing the specified elements
Throws
NullPointerException if any of the specified elements is null

public static EnumSet<E> range (E start, E end)

Creates an enum set containing all the elements within the range defined by start and end (inclusive). All the elements must be in order.

Parameters
start the element used to define the beginning of the range
end the element used to define the end of the range
Returns
  • an enum set with elements in the range from start to end
Throws
NullPointerException if any one of start or end is null
IllegalArgumentException if start is behind end