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.
Creates an Enum with the given key-value mapping.
Static Methods Detail Top
static
public
String
nameOf
( Object instance, * value )
Returns the name of an enuerated value given the enumeration and the 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.
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
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