Class: Enum

lang.Enum(name, ordinal)

This is a base class for creating enum objects.

Example:

class YesNo extends Enum {
  static YES = new YesNo('YES', 0);
  static NO = new YesNo('NO', 1);
}

Constructor

new Enum(name, ordinal)

Creates an enum object.

Parameters:
Name Type Description
name string

The name of the enum constant.

ordinal number

The ordinal of the enum constant.

Methods

toJSON() → {string}

Returns the name of the enum constant.

Returns:

The name of the enum constant.

Type
string

toString() → {string}

Returns the name of the enum constant.

Returns:

The name of the enum constant.

Type
string

valueOf() → {number}

Returns the ordinal of the enum constant.

Returns:

The ordinal of the enum constant.

Type
number

(static) valueOf(name) → {Enum}

Returns an enum constant by its name.

Parameters:
Name Type Description
name string

The name of the enum constant.

Returns:

The enum constant.

Type
Enum

(static) values() → {Array.<Enum>}

Returns all enum constants.

Returns:

All enum constants.

Type
Array.<Enum>