Class: BitmaskEnum

util~ BitmaskEnum

An immutable enum-like object with an associated bitmask support.

This class is essentially abstract, and must be extended by another class that overrides the inerited module:util~Enum.enumValues method.


<abstract> new BitmaskEnum(name, bitNumber)

Constructor.

Extends:
Parameters:
Name Type Description
name string

the name

bitNumber number

the bit offset, starting from 1 for the least significant bit

Extends

Members


bitmaskBitNumber

Get the bit offset value, starting from 1 for the least significant bit.


bitmaskBitOffset

Get the bit offset value, starting from 0 for the least significant bit.


name

Get the enum name.

Inherited From:

Methods


<static> bitmaskValue(maskables)

Get a bitmask value for a set of {@code Bitmaskable} objects.

Parameters:
Name Type Description
maskables Iterable.<BitmaskEnum>

the set of BitmaskEnum objects

Returns:

a bitmask value of all module:util~BitmaskEnum#bitmaskBitOffset() values of the given maskables

Type
number

<static> enumForBitNumber(bitNumber, values)

Get a BitmaskEnum objects for a bit number.

Parameters:
Name Type Description
bitNumber number

a bit number value of the BitmaskEnum object to find

values Iterable.<BitmaskEnum>

the complete set of possible BitmaskEnum objects

Returns:

the matching BitmaskEnum, or null

Type
BitmaskEnum

<static> setForBitmask(mask, values)

Convert a bitmask value into a set of BitmaskEnum objects.

Parameters:
Name Type Description
mask number

a bitmask value of a set of BitmaskEnum objects

values Iterable.<BitmaskEnum>

the complete set of possible BitmaskEnum objects

Returns:

a set of BitmaskEnum objects

Type
Set.<BitmaskEnum>

<static> setForBitmaskEnum(mask, clazz)

Convert a bitmask value into a set of {@code Bitmaskable} objects.

Parameters:
Name Type Description
mask number

a bitmask value of a set of {@code Bitmaskable} objects

clazz BitmaskEnum

the class of an enumeration of BitmaskEnum objects

Returns:

a set of BitmaskEnum objects

Type
Set.<BitmaskEnum>

equals(value)

Test if a string is equal to this enum's name.

As long as enum values are consistently obtained from the module:util~Enum.enumValues array then enum instances can be compared with ===. If unsure, this method can be used to compare string values instead.

If value is passed as an actual Enum instance, then if that enum is the same class as this enum it's name is compared to this instance's name.

Parameters:
Name Type Description
value string | Enum

the value to test

Inherited From:
Returns:

true if value is the same as this instance's name value

Type
boolean