DynamicEnum

baja. DynamicEnum

new DynamicEnum()

Description:
  • Represents a baja:DynamicEnum in BajaScript.

    DynamicEnum stores an ordinal state variable as
    a Number. An instance of EnumRange may be used to specify the range.

    When creating a Simple, always use the make() method instead of
    creating a new Object.

Source:

Extends

Members

(static) DEFAULT :baja.DynamicEnum

Description:
  • Default DynamicEnum instance.

Source:

Default DynamicEnum instance.

Type:

Methods

decodeAsync(str, batchopt) → {Promise.<string>}

Description:
  • Asynchronously decode a DynamicEnum from a string, including importing
    any type spec encoded in the range.

Source:
Overrides:
Parameters:
Name Type Attributes Description
str string
batch baja.comm.Batch <optional>
Returns:
Type
Promise.<string>

decodeFromString(str, paramsopt) → {baja.DynamicEnum}

Description:
  • Decode a DynamicEnum from a String.

Source:
Overrides:
Parameters:
Name Type Attributes Description
str String
params Object <optional>
Properties
Name Type Attributes Default Description
unsafe Boolean <optional>
false

if set to true, this will allow
decodeFromString to continue. If not, decodeFromString will throw an error. This flag is for
internal bajaScript use only. All external implementations should use decodeAsync instead.

Returns:
Type
baja.DynamicEnum

encodeToString() → {String}

Description:
  • Encode a DynamicEnum to a String.

Source:
Overrides:
Returns:
Type
String

equals(obj) → {Boolean}

Description:
  • Equality test.

Source:
Inherited From:
Parameters:
Name Type Description
obj
Returns:
Type
Boolean

equivalent(obj) → {Boolean}

Description:
  • Equivalence test.

    equivalent() is used to compare if two Objects have equivalent
    state, but might not want to return true for equals since it
    it has implied semantics for many operations. The default
    implementation returns the result of baja.Object#equals.

Source:
Inherited From:
Parameters:
Name Type Description
obj
Returns:
Type
Boolean

get(arg) → {baja.DynamicEnum}

Description:
  • Get the enum for the specified tag or ordinal.

    This method is used to access an enum based upon a tag or ordinal.

Source:
Since:
  • Niagara 4.6
Parameters:
Name Type Description
arg String | Number | baja.Simple

a tag or ordinal (any baja:Number
type).

Throws:

if the tag or ordinal is invalid.

Type
Error
Returns:

the enum for the tag or ordinal.

Type
baja.DynamicEnum

getAgents(isopt, batchopt) → {Promise}

Description:
  • Returns a promise that resolves to the agent list for this Object.

Source:
Inherited From:
See:
Parameters:
Name Type Attributes Description
is Array.<String> <optional>

An optional array of filters to add to the
agent query.

batch baja.comm.Batch <optional>

An optional object used to batch network
calls together.

Returns:

A promise that will resolve with the Agent Info.

Type
Promise

getDataTypeSymbol() → {String}

Description:
  • Return the data type symbol.

Source:
Returns:

the data type symbol.

Type
String

getEnum() → {baja.Enum}

Description:
  • Return the Enum (itself).

Source:
Inherited From:
Returns:
Type
baja.Enum

getIcon() → {baja.Icon}

Description:
  • Return the Object's Icon.

Source:
Inherited From:
Returns:
Type
baja.Icon

getOrdinal() → {Number}

Description:
  • Return the ordinal.

Source:
Returns:

the ordinal.

Type
Number

getRange() → {baja.EnumRange}

Description:
  • Return the range.

Source:
Returns:

the enum range.

Type
baja.EnumRange

getTag() → {String}

Description:
  • Return the tag for the ordinal.

Source:
Returns:

the tag.

Type
String

getType() → {Type}

Description:
  • Get the type of this instance.

Source:
Inherited From:
Returns:
Type
Type

getTypeDisplayName(cxopt) → {Promise.<string>|string}

Description:
  • Gets the friendly type display name for this object.

Source:
Since:
  • Niagara 4.10
Inherited From:
See:
  • baja.Type#getDisplayName
Parameters:
Name Type Attributes Description
cx Object <optional>

a context to be passed down to Type

Returns:

If no context is provided, the type
display name is returned synchronously as a string. If context provided,
the type display name is resolved via a promise as a string.

Type
Promise.<string> | string

is(arg) → {Boolean}

Description:
  • Equals comparison via tag or ordinal.

Source:
Parameters:
Name Type Description
arg String | Number | baja.DynamicEnum

the enum, tag or ordinal used for comparison.

Returns:

true if equal.

Type
Boolean

isActive() → {Boolean}

Description:
  • Return whether the enum is active or not.

Source:
Returns:

true if active.

Type
Boolean

make(objopt) → {baja.DynamicEnum}

Description:
  • Make a DynamicEnum.

Source:
Overrides:
Example
// An ordinal or an Object Literal can be used for the method's arguments...
  var de1 = baja.$("baja:DynamicEnum").make(0); // Just with an ordinal

  //... or with an Object Literal...

  var de2 = baja.$("baja:DynamicEnum").make({ordinal: 0, range: enumRange});
  
  //...or create from another enumeration...

  var de3 = baja.$("baja:DynamicEnum").make({en: anEnum});
Parameters:
Name Type Attributes Description
obj Object | Number <optional>

the Object Literal for the method's arguments or an ordinal.

Properties
Name Type Attributes Description
ordinal Number <optional>

the ordinal for the enum. If omitted it
defaults to the first ordinal in the range or 0 if the range has no
ordinals.

en baja.DynamicEnum | baja.FrozenEnum | Boolean | String <optional>

if defined, this enum will be used for the ordinal and range.
As well as an enum, this can also be a TypeSpec
String (moduleName:typeName) for a FrozenEnum.

Returns:

the DynamicEnum.

Type
baja.DynamicEnum

newCopy(exactopt)

Description:
  • Every value may be cloned using the newCopy method.

    Please note that Simples are immutable so they don't
    allocate a new instance.

Source:
Inherited From:
See:
Parameters:
Name Type Attributes Description
exact Boolean <optional>

true if an exact copy of the value should be
made (only valid in the Component architecture).

Returns:

a copy of the value (or the same instance if the value is a
Simple).

toString(cxopt) → {String|Promise.<String>}

Description:
  • Return the String representation of the DynamicEnum.

Source:
Overrides:
Parameters:
Name Type Attributes Description
cx Object <optional>
Properties
Name Type Attributes Description
range baja.EnumRange <optional>

range to use when formatting the string.
If not provided, the range configured on the DynamicEnum directly will be
used.

Returns:

a string representation of this
DynamicEnum (Promise if context given; String if no context given)

Type
String | Promise.<String>

valueOf() → {Number}

Description:
  • Return the ordinal of the Enum (itself).

Source:
Inherited From:
Returns:
Type
Number

(static) make(objopt) → {baja.DynamicEnum}

Description:
  • Make a DynamicEnum.

Source:
Example
//An ordinal or an Object Literal can be used for the method's arguments...
  var de1 = baja.DynamicEnum.make(0); // Just with an ordinal

  //... or with an Object Literal...

  var de2 = baja.DynamicEnum.make({ordinal: 0, range: enumRange});
  
  //...or create from another enumeration...

  var de3 = baja.DynamicEnum.make({en: anEnum});
Parameters:
Name Type Attributes Description
obj Object | Number <optional>

the Object Literal for the method's arguments or an ordinal.

Properties
Name Type Attributes Description
ordinal Number <optional>

the ordinal for the enum. If omitted it
defaults to the first ordinal in the range or 0 if the range has no
ordinals.

range baja.EnumRange <optional>

the range for the enum.

en baja.DynamicEnum | baja.FrozenEnum | Boolean | String <optional>

if defined, this enum will be used for the ordinal and range.
As well as an enum, this can also be a TypeSpec
String (moduleName:typeName) for a FrozenEnum.

Returns:

the DynamicEnum.

Type
baja.DynamicEnum