Facets

baja. Facets

new Facets()

Description:
  • Represents a baja:Facets in BajaScript.

    BFacets is a map of name/value pairs used to annotate a
    BComplex's Slot or to just provide additional metadata
    about something. The values of facets may only be
    BIDataValues which are a predefined subset of simples.

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

Source:

Extends

Members

decodeFromString

Description:
  • Decode a String to a Facets.

Source:
Overrides:

Decode a String to a Facets.

(static) DEFAULT :baja.Facets

Description:
  • Default Facets instance.

Source:

Default Facets instance.

Type:

(static) NULL :baja.Facets

Description:
  • NULL Facets instance.

Source:

NULL Facets instance.

Type:

Methods

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

Description:
  • Decode a String to a Facets, doing an async decode on each individual
    encoded Simple.

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

encodeToString() → {String}

Description:
  • Encode Facets 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(key, defopt)

Description:
  • Return a value from the map for the given key.

Source:
Parameters:
Name Type Attributes Description
key String

the key used to look up the data value

def <optional>

if defined, this value is returned if the key can't be found.

Returns:

the data value for the key (null if not found)

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

getIcon() → {baja.Icon}

Description:
  • Return the Object's Icon.

Source:
Inherited From:
Returns:
Type
baja.Icon

getKeys() → {Array.<String>}

Description:
  • Return a copy of the Facets keys.

Source:
Returns:

all of the keys used in the Facets

Type
Array.<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

make()

Description:
Source:
Overrides:
See:

makeRemove(key) → {baja.Facets}

Description:
  • Removes the key from the provided facets and returns a new facets. If the orig facets doesn't
    contain the specified key then return the original instance.

Source:
Since:
  • Niagara 4.14
Parameters:
Name Type Description
key String

the key in the facets to remove

Returns:
Type
baja.Facets

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).

toObject() → {Object}

Description:
  • Converts the Facets (itself) to an object literal.

Source:
Returns:
Type
Object

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

Description:
  • Return a String representation of the Facets.

Source:
Overrides:
Parameters:
Name Type Attributes Description
cx Object <optional>

Passed directly into the toString() functions of the
individual Simples within. Object Literal used to specify formatting
facets.

Returns:

returns a Promise if a cx is passed in.

Type
String | Promise.<String>

valueOf() → {String}

Description:
  • Return the value of the Facets.

Source:
Overrides:
Returns:
Type
String

(static) getFacetsFromObject(obj) → {baja.Facets}

Description:
  • Return the facets for the given object.

    If the object is a Facets, that object is returned.

    If the object has a facets slot, the value of that slot is returned.

    If the object has a parent, the Facets from the object's parent slot is
    returned.

    If the facets can't be found then baja.Facets.DEFAULT is returned.

Source:
Parameters:
Name Type Description
obj
Returns:
Type
baja.Facets

(static) make(keys, valuesopt) → {baja.Facets}

Description:
  • Make a Facets object. This function can either take two Array objects
    for keys and values, two Facets or two object literals. In the latter two
    cases, a new Facets object will be returned containing a combination of
    keys and values from both input Facets objects. If a key exists on both
    Facets objects, the value from the second Facets will take precedence.

Source:
Example
var facets1 = baja.Facets.make(['a', 'b'], ['1', '2']);
  var facets2 = baja.Facets.make(['b', 'c'], ['3', '4']);
  var facets3 = baja.Facets.make(facets1, facets2);
  baja.outln(facets3.get('a')); //1
  baja.outln(facets3.get('b')); //3 - facets2 overwrote value in facets1
  baja.outln(facets3.get('c')); //4
Parameters:
Name Type Attributes Description
keys Array.<String> | baja.Facets | Object

an array of keys for the
facets. The keys must be Strings. (This may also be a Facets (or object
literal) whose values will be combined with the second parameter. Values in
this object will be overwritten by corresponding values from the other).

values Array.<baja.Simple> | baja.Facets | Object <optional>

an array of values
for the facets. The values must be BajaScript Objects whose Type
implements BIDataValue. (This may also be a Facets (or object literal)
object whose values will be combined with the first parameter. Values in
this object will overwrite corresponding values on the other.)

Returns:

the Facets

Type
baja.Facets

(static) mergeSlotFacets(containeropt, propertyPathopt) → {baja.Facets}

Description:
  • Get the slot facets from a container, merged all the way down through a
    property path or slot.

Source:
Since:
  • Niagara 4.10
Parameters:
Name Type Attributes Description
container baja.Complex <optional>
propertyPath Array.<(baja.Property|string)> | baja.Property | string <optional>
Returns:
Type
baja.Facets