E - The type of Enum objects contained in this set.@Immutable public final class BitField<E extends Enum<E>> extends Object implements Iterable<E>, Serializable
| Modifier and Type | Method and Description |
|---|---|
static <E extends Enum<E>> |
allOf(Class<E> elementType)
Returns a bit field which contains all enums of the given element type.
|
BitField<E> |
and(BitField<E> that) |
int |
cardinality()
Returns the number of bits set in this field.
|
BitField<E> |
clear(E bit)
Clears the given bit.
|
static <E extends Enum<E>> |
copyOf(Collection<E> bits)
Returns a bit field which contains the same bits as the given collection
of enums.
|
boolean |
equals(Object that)
Returns
true if and only if the given object is another
BitField and contains the same bits. |
boolean |
get(E bit)
Returns
true if and only if the given bit is set. |
int |
hashCode()
Returns a hash code which is consistent with
equals(java.lang.Object). |
boolean |
is(E bit)
Equivalent to
get(bit). |
boolean |
isEmpty()
Returns
true if and only if all bits are cleared in this bit
field. |
Iterator<E> |
iterator()
Returns a read-only iterator for the bits in this field.
|
static <E extends Enum<E>> |
noneOf(Class<E> elementType)
Returns a bit field which can contain the given element type and is
initially empty.
|
BitField<E> |
not() |
static <E extends Enum<E>> |
of(Class<E> elementType,
String list) |
static <E extends Enum<E>> |
of(E bit)
Returns a bit field which contains the given bit.
|
static <E extends Enum<E>> |
of(E bit,
E... bits)
Returns a bit field which contains the given bits.
|
BitField<E> |
or(BitField<E> that) |
BitField<E> |
set(E bit)
Sets the given bit.
|
BitField<E> |
set(E bit,
boolean set)
Sets or clears the given bit.
|
EnumSet<E> |
toEnumSet()
Returns a new set of enums containing the same bits as this instance.
|
String |
toString()
Returns a concatenation of the names of the bits in this field,
separated by
"|". |
public static <E extends Enum<E>> BitField<E> allOf(Class<E> elementType)
This could be used like this:
BitField<Option> field = BitField.allOf(Option.class);
where Option is an arbitrary enum type.public int cardinality()
public static <E extends Enum<E>> BitField<E> copyOf(Collection<E> bits)
This could be used like this:
BitField<Option> field = BitField.of(bits);
where bits is an EnumSet<Option>.public boolean equals(@CheckForNull Object that)
true if and only if the given object is another
BitField and contains the same bits.public boolean get(E bit)
true if and only if the given bit is set.bit - The bit to test.public int hashCode()
equals(java.lang.Object).public boolean isEmpty()
true if and only if all bits are cleared in this bit
field.public static <E extends Enum<E>> BitField<E> noneOf(Class<E> elementType)
This could be used like this:
BitField<Option> field = BitField.noneOf(Option.class);
where Option is an arbitrary enum type.public static <E extends Enum<E>> BitField<E> of(E bit)
This could be used like this:
BitField<Option> field = BitField.of(Option.ONE);
where Option.ONE is an arbitrary enum.public static <E extends Enum<E>> BitField<E> of(E bit, E... bits)
This could be used like this:
BitField<Option> field = BitField.of(Option.ONE, Option.TWO);
where Option.ONE and Option.TWO are arbitrary enums.public BitField<E> set(E bit, boolean set)
Subclasses could override this method in order to cache frequently used results, such as a null bit field, a single bit field etc.
bit - The bit to set or clear.set - Whether the bit shall get set or cleared.public EnumSet<E> toEnumSet()
null bit field bits:
bits.equals(BitField.copyOf(bits.toEnumSet())).Copyright © 2005-2013 Schlichtherle IT Services. All Rights Reserved.