Version: 10.17.1
Mixin

solace.Enum

Contents

mixin solace.Enum

Creates an Enum with the given key-value mapping.

Constructor Top

  Enum ( Object values )

Properties Top

readonly isEnum
readonly names
readonly values

Static Methods Top

String nameOf ( Object instance, * value )
Array values ( Object instance )

Methods Top

String describe ( any enumValue, String noneValue, String unknownValue )
String nameOf ( any enumValue )

Constructor details Top

static public Enum ( Object values )

Creates an Enum with the given key-value mapping.

Parameters

Object values

The key-value mapping to use. This mapping is set as the initial canonical key-value mapping. To override, use solace.Enum#_setCanonical.

Static Methods Detail Top

static public String nameOf ( Object instance, * value )

Returns the name of an enuerated value given the enumeration and the value.

Parameters

Object instance

The enumeration instance.

* value

The value for which to return the key name.

Return Value

String

The key name for the given enumeration value.

static public Array values ( Object instance )

Returns values defined on this enumeration for the given keys. To get the enumeration keys, use Object#keys.

Parameters

Object instance

The enumeration on which to return values.

Return Value

Array

The values defined on the given enumeration.

Properties Detail Top

public readonly isEnum

A property returning true to faciliate duck-typing with {solace.Enum} objects.

public readonly names

Returns all canonical names/keys in this enumeration.

public readonly values

Returns all values assigned to canonical keys in this enumeration.

Methods Detail Top

public String describe ( any enumValue, String noneValue, String unknownValue )

Create a human-readable string describing the given enumeration value. This result is informational and may vary between SDK versions.

Currently, it either returns the value provided (if the associated key is the same), or a string of the form key (value).

Example

console.log(new Enum({ ANSWER: 42 }).describe(42)); // ANSWER (42)
console.log(new Enum({ ECHO: 'ECHO' })).describe('ECHO'); // ECHO

Parameters

any enumValue

The value on which to perform reverse mapping.

String noneValue = ''

The string to return if the enumeration value is undefined or null.

(Optional)

String unknownValue = ''

The string to return if the enumeration value was not found in any of the canonical keys.

(Optional)

Return Value

String

A human-readable description of the reverse mapping for the value.

public String nameOf ( any enumValue )

Returns the canonical name in this enumeration for the given value. This function is designed to facilitate reflection, whereas for display

Parameters

any enumValue

The value for which to get the enumeration key.

Return Value

String

The name for the given value.