Class: Enum

util~ Enum

An enumerated object base class.

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


<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 given name

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.

Parameters:
Name Type Description
value string

the value to test

Returns:

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

Type
boolean