Constructor
(abstract) new Enum(name)
Constructor.
| Name | Type | Description |
|---|---|---|
name | string | the name |
- Source
Members
name
Get the enum name.
- Source
Methods
equals(value) → {boolean}
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.
| Name | Type | Description |
|---|---|---|
value | string | | the value to test |
- Source
true if value is the same as this instance's name value
- Type:
- boolean
(abstract, static) enumValues() → {Array.<module:util~Enum>}
Get all enum values.
This method must be overridden by subclasses to return something meaningful. This implementation returns an empty array.
- Source
get all enum values
- Type:
- Array.<module:util~Enum>
(static) enumsValue(enums) → {object}
This method takes an array of enums and turns them into a mapped object, using the enum name as object property names.
| Name | Type | Description |
|---|---|---|
enums | Array.<module:util~Enum> | the enum list to turn into a value object |
- Source
an object with enum name properties with associated enum values
- Type:
- object
(static) namesFor(set) → {Array.<string>}
Get the names of a set of Enum instances.
| Name | Type | Description |
|---|---|---|
set | Array.<Enum> | the set of |
- Source
array of Enum name values
- Type:
- Array.<string>
(static) valueOf(name) → {module:util~Enum}
Get an enum instance from its name.
This method searches the module:util~Enum#enumVvalues array for a matching value.
| Name | Type | Description |
|---|---|---|
name | string | the enum name to get an instnace for |
- Source
the instance, or undefined if no instance exists for the given name
- Type:
- module:util~Enum