Class: Enum

Enum

Reflected enum.

new Enum(name, values, options, comment, comments, valuesOptions)

Constructs a new enum instance.

Name Type Description
name string

Unique name within its namespace

values Object.<string, number> optional

Enum values as an object, by name

options Object.<string, *> optional

Declared options

comment string optional

The comment for this enum

comments Object.<string, string> optional

The value comments for this enum

valuesOptions Object.<string, Object.<string, *>> | undefined optional

The value options for this enum

Extends

Members

comment { string | null }

Enum comment text.

comments { Object<string, string> }

Value comment texts, if any.

filename { string | null }

Defining file name.

fullName readonly{ string }

Full name including leading dot.

name { string }

Unique name within its namespace.

options { Object<string, *> | undefined }

Options.

parent { Namespace | null }

Parent namespace.

parsedOptions { Object<string, *>[] | undefined }

Parsed Options.

reserved { (number[]|string)[] }

Reserved ranges, if any.

resolved { boolean }

Whether already resolved or not.

root readonly{ Root }

Reference to the root namespace.

values { Object<string, number> }

Enum values by name.

valuesById { Object<number, string> }

Enum values by id.

valuesOptions { Object<string, Object<string, *>> | undefined }

Values options, if any

Methods

add(name, id, comment, options){ Enum }

Adds a value to this enum.

Name Type Description
name string

Value name

id number

Value id

comment string optional

Comment, if any

options Object.<string, *> | undefined optional

Options, if any

Throws:
  • Type Description
    TypeError

    If arguments are invalid

  • Type Description
    Error

    If there is already a value with this name or id

Returns:
Type Description
Enum this

inherited getOption(name){ * }

Gets an option value.

Name Type Description
name string

Option name

Returns:
Type Description
* Option value or undefined if not set

isReservedId(id){ boolean }

Tests if the specified id is reserved.

Name Type Description
id number

Id to test

Returns:
Type Description
boolean true if reserved, otherwise false

isReservedName(name){ boolean }

Tests if the specified name is reserved.

Name Type Description
name string

Name to test

Returns:
Type Description
boolean true if reserved, otherwise false

inherited onAdd(parent){ undefined }

Called when this object is added to a parent.

Name Type Description
parent ReflectionObject

Parent added to

Returns:
Type Description
undefined

inherited onRemove(parent){ undefined }

Called when this object is removed from a parent.

Name Type Description
parent ReflectionObject

Parent removed from

Returns:
Type Description
undefined

remove(name){ Enum }

Removes a value from this enum

Name Type Description
name string

Value name

Throws:
  • Type Description
    TypeError

    If arguments are invalid

  • Type Description
    Error

    If name is not a name of this enum

Returns:
Type Description
Enum this

Resolves this objects type references.

Returns:
Type Description
ReflectionObject this

inherited setOption(name, value, ifNotSet){ ReflectionObject }

Sets an option.

Name Type Description
name string

Option name

value *

Option value

ifNotSet boolean | undefined optional

Sets the option only if it isn't currently set

Returns:
Type Description
ReflectionObject this

inherited setOptions(options, ifNotSet){ ReflectionObject }

Sets multiple options.

Name Type Description
options Object.<string, *>

Options to set

ifNotSet boolean optional

Sets an option only if it isn't currently set

Returns:
Type Description
ReflectionObject this

inherited setParsedOption(name, value, propName){ ReflectionObject }

Sets a parsed option.

Name Type Description
name string

parsed Option name

value *

Option value

propName string

dot '.' delimited full path of property within the option to set. if undefined\empty, will add a new option with that value

Returns:
Type Description
ReflectionObject this

toJSON(toJSONOptions){ IEnum }

Converts this enum to an enum descriptor.

Name Type Description
toJSONOptions IToJSONOptions optional

JSON conversion options

Returns:
Type Description
IEnum Enum descriptor

inherited toString(){ string }

Converts this instance to its string representation.

Returns:
Type Description
string Class name[, space, full name]

Enum.fromJSON(name, json){ Enum }

Constructs an enum from an enum descriptor.

Name Type Description
name string

Enum name

json IEnum

Enum descriptor

Throws:
Type Description
TypeError

If arguments are invalid

Returns:
Type Description
Enum Created enum