public abstract class FlagsEnum<T extends FlagsEnum> extends Number
Practically, a FlagsEnum collections consists of a number of constant FlagsEnums. Those are pairs of an integer ordinal number and a string identifier.
ExamplePredefined constants: Ordinal - Flag Name 0 - Black 1 - Red 2 - Green 4 - Blue All possible combinations of values of those constants produced by bitwise operations: 0 - Black 1 - Red 2 - Green 3 - Red, Green 4 - Blue 5 - Red, Blue 6 - Green, Blue 7 - Red, Green, Blue
Modifier | Constructor and Description |
---|---|
protected |
FlagsEnum(int ordinal,
String name) |
Modifier and Type | Method and Description |
---|---|
T |
and(T other)
Logically combines this FlagsEnum with another FlagsEnum to create
a new instance that is equal to the original FlagsEnum
AND the other FlagsEnum.
|
static <T extends FlagsEnum<T>> |
and(T t1,
T t2)
Static convenience method that is semantically identical to the non-static method
and(FlagsEnum) |
boolean |
contains(FlagsEnum<T> other)
Determines whether any flag in
other is also contained in this instance. |
boolean |
containsAll(FlagsEnum<T> other)
Determines whether all flags in
other are also contained in this instance. |
double |
doubleValue() |
boolean |
equals(Object o) |
static <T extends FlagsEnum<T>> |
equals(T t1,
T t2) |
float |
floatValue() |
protected abstract T |
fromOrdinalImpl(int ordinal) |
protected abstract T[] |
getItems()
Returns all items defined in this FlagsEnum.
|
int |
hashCode() |
int |
intValue() |
T |
inverse()
Returns a FlagsEnum that is the inverse to this FlagsEnum.
|
static <T extends FlagsEnum<T>> |
inverse(T t)
Static convenience method that is semantically identical to the non-static method
inverse() |
long |
longValue() |
boolean |
notContains(FlagsEnum<T> other)
Determines whether none of the flags in
other are also contained in this instance. |
static <T extends FlagsEnum<T>> |
notEquals(T t1,
T t2) |
T |
or(T other)
Logically combines this FlagsEnum with another FlagsEnum to create
a new instance that is equal to the original FlagsEnum
OR the other FlagsEnum.
|
static <T extends FlagsEnum<T>> |
or(T t1,
T t2)
Static convenience method that is semantically identical to the non-static method
or(FlagsEnum) |
int |
ordinal()
Returns the integer ordinal number for this flag.
|
String |
toString() |
T |
xor(T other)
Logically combines this FlagsEnum with another FlagsEnum to create
a new instance that is equal to the original FlagsEnum
XOR the other FlagsEnum.
|
static <T extends FlagsEnum<T>> |
xor(T t1,
T t2)
Static convenience method that is semantically identical to the non-static method
xor(FlagsEnum) |
byteValue, shortValue
protected FlagsEnum(int ordinal, String name)
public final T and(T other)
other
- Another FlagsEnum.public static final <T extends FlagsEnum<T>> T and(T t1, T t2)
and(FlagsEnum)
public final boolean contains(FlagsEnum<T> other)
other
is also contained in this instance.true
if any flag in other
is also contained in this instance; otherwise, false
.public final boolean containsAll(FlagsEnum<T> other)
other
are also contained in this instance.true
if all flags in other
are also contained in this instance; otherwise, false
.public double doubleValue()
doubleValue
in class Number
public static final <T extends FlagsEnum<T>> boolean equals(T t1, T t2)
public float floatValue()
floatValue
in class Number
protected abstract T fromOrdinalImpl(int ordinal)
protected abstract T[] getItems()
public final T inverse()
public static final <T extends FlagsEnum<T>> T inverse(T t)
inverse()
public final boolean notContains(FlagsEnum<T> other)
other
are also contained in this instance.true
if none of the flags in other
are also contained in this instance; otherwise, false
.public static final <T extends FlagsEnum<T>> boolean notEquals(T t1, T t2)
public final T or(T other)
other
- Another FlagsEnum.public static final <T extends FlagsEnum<T>> T or(T t1, T t2)
or(FlagsEnum)
public final int ordinal()
public final T xor(T other)
other
- Another FlagsEnum.public static final <T extends FlagsEnum<T>> T xor(T t1, T t2)
xor(FlagsEnum)