FileDocCategorySizeDatePackage
EnumSet.javaAPI DocAndroid 1.5 API12519Wed May 06 22:41:04 BST 2009java.util

EnumSet

public abstract class EnumSet extends AbstractSet implements Serializable, Cloneable
An EnumSet is a specialized Set to be used with enums as keys.
since
Android 1.0

Fields Summary
static org.apache.harmony.kernel.vm.LangAccess
LANG_BOOTSTRAP
private static final long
serialVersionUID
final Class
elementClass
Constructors Summary
EnumSet(Class cls)


      
        elementClass = cls;
    
Methods Summary
public static java.util.EnumSetallOf(java.lang.Class elementType)
Creates an enum set filled with all the enum elements of the specified {@code elementType}.

param
elementType the class object for the elements contained.
return
an enum set with elements solely from the specified element type.
throws
ClassCastException if the specified element type is not and enum type.
since
Android 1.0

        EnumSet<E> set = noneOf(elementType);
        set.complement();
        return set;
    
public java.util.EnumSetclone()
Creates a new enum set with the same elements as those contained in this enum set.

return
a new enum set with the same elements as those contained in this enum set.
since
Android 1.0

        try {
            Object set = super.clone();
            return (EnumSet<E>) set;
        } catch (CloneNotSupportedException e) {
            return null;
        }
    
abstract voidcomplement()

public static java.util.EnumSetcomplementOf(java.util.EnumSet s)
Creates an enum set. All the contained elements complement those from the specified enum set.

param
s the specified enum set.
return
an enum set with all the elements complementary to those from the specified enum set.
since
Android 1.0

        EnumSet<E> set = EnumSet.noneOf(s.elementClass);
        set.addAll(s);
        set.complement();
        return set;
    
public static java.util.EnumSetcopyOf(java.util.EnumSet s)
Creates an enum set. All the contained elements are of type Class<E>, and the contained elements are the same as those contained in {@code s}.

param
s the enum set from which to copy.
return
an enum set with all the elements from the specified enum set.
throws
ClassCastException if the specified element type is not and enum type.
since
Android 1.0

        EnumSet<E> set = EnumSet.noneOf(s.elementClass);
        set.addAll(s);
        return set;
    
public static java.util.EnumSetcopyOf(java.util.Collection c)
Creates an enum set. The contained elements are the same as those contained in collection {@code c}. If c is an enum set, invoking this method is the same as invoking {@link #copyOf(EnumSet)}.

param
c the collection from which to copy. if it is not an enum set, it must not be empty.
return
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.
since
Android 1.0

        if (c instanceof EnumSet) {
            return copyOf((EnumSet<E>) c);
        }
        if (0 == c.size()) {
            throw new IllegalArgumentException();
        }
        Iterator<E> iterator = c.iterator();
        E element = iterator.next();
        EnumSet<E> set = EnumSet.noneOf(element.getDeclaringClass());
        set.add(element);
        while (iterator.hasNext()) {
            set.add(iterator.next());
        }
        return set;
    
booleanisValidType(java.lang.Class cls)

        return cls == elementClass || cls.getSuperclass() == elementClass;
    
public static java.util.EnumSetnoneOf(java.lang.Class elementType)
Creates an empty enum set. The permitted elements are of type Class<E>.

param
elementType the class object for the elements contained.
return
an empty enum set, with permitted elements of type {@code elementType}.
throws
ClassCastException if the specified element type is not and enum type.
since
Android 1.0

        if (!elementType.isEnum()) {
            throw new ClassCastException();
        }
        // BEGIN android-changed
        E[] enums = SpecialAccess.LANG.getEnumValuesInOrder(elementType);
        if (enums.length <= 64) {
            return new MiniEnumSet<E>(elementType, enums);
        }
        return new HugeEnumSet<E>(elementType, enums);
        // END android-changed
    
public static java.util.EnumSetof(E e1, E e2, E e3)
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 an arbitrary number of elements, and runs slower than those that only receive a fixed number of elements.

param
e1 the initially contained element.
param
e2 another initially contained element.
param
e3 another initially contained element.
return
an enum set containing the specified element.
since
Android 1.0

        EnumSet<E> set = of(e1, e2);
        set.add(e3);
        return set;
    
public static java.util.EnumSetof(E e1, E e2, E e3, E e4)
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 an arbitrary number of elements, and runs slower than those that only receive a fixed number of elements.

param
e1 the initially contained element.
param
e2 another initially contained element.
param
e3 another initially contained element.
param
e4 another initially contained element.
return
an enum set containing the specified element.
since
Android 1.0

        EnumSet<E> set = of(e1, e2, e3);
        set.add(e4);
        return set;
    
public static java.util.EnumSetof(E e1, E e2, E e3, E e4, E e5)
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 an arbitrary number of elements, and runs slower than those that only receive a fixed number of elements.

param
e1 the initially contained element.
param
e2 another initially contained element.
param
e3 another initially contained element.
param
e4 another initially contained element.
param
e5 another initially contained element.
return
an enum set containing the specified element.
since
Android 1.0

        EnumSet<E> set = of(e1, e2, e3, e4);
        set.add(e5);
        return set;
    
public static java.util.EnumSetof(E start, E others)
Creates a new enum set, containing only the specified elements. It can receive an arbitrary number of elements, and runs slower than those only receiving a fixed number of elements.

param
start the first initially contained element.
param
others the other initially contained elements.
return
an enum set containing the specified elements.
since
Android 1.0

        EnumSet<E> set = of(start);
        for (E e : others) {
            set.add(e);
        }
        return set;
    
public static java.util.EnumSetof(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 an arbitrary number of elements, and runs slower than those that only receive a fixed number of elements.

param
e the element to be initially contained.
return
an enum set containing the specified element.
since
Android 1.0

        EnumSet<E> set = EnumSet.noneOf(e.getDeclaringClass());
        set.add(e);
        return set;
    
public static java.util.EnumSetof(E e1, E e2)
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 an arbitrary number of elements, and runs slower than those that only receive a fixed number of elements.

param
e1 the initially contained element.
param
e2 another initially contained element.
return
an enum set containing the specified element.
since
Android 1.0

        EnumSet<E> set = of(e1);
        set.add(e2);
        return set;
    
public static java.util.EnumSetrange(E start, E end)
Creates an enum set containing all the elements within the range defined by {@code start} and {@code end} (inclusive). All the elements must be in order.

param
start the element used to define the beginning of the range.
param
end the element used to define the end of the range.
return
an enum set with elements in the range from start to end.
throws
IllegalArgumentException if {@code start} is behind {@code end}.
since
Android 1.0

        if (start.compareTo(end) > 0) {
            throw new IllegalArgumentException();
        }
        EnumSet<E> set = EnumSet.noneOf(start.getDeclaringClass());
        set.setRange(start, end);
        return set;
    
abstract voidsetRange(E start, E end)

java.lang.ObjectwriteReplace()

        SerializationProxy proxy = new SerializationProxy();
        proxy.elements = toArray(new Enum[0]);
        proxy.elementType = elementClass;
        return proxy;