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