new Facets()
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.
Extends
Members
-
<static> DEFAULT :baja.Facets
-
Default
Facetsinstance.Type:
-
<static> NULL :baja.Facets
-
NULL
Facetsinstance.Type:
-
decodeFromString
-
Decode a
Stringto aFacets.- Overrides:
Methods
-
<static> getFacetsFromObject(obj)
-
Return the facets for the given object.
If the object is a
Facets, that object is returned.If the object has a
facetsslot, the value of that slot is returned.If the object has a parent, the
Facetsfrom the object's parent slot is
returned.If the facets can't be found then baja.Facets.DEFAULT is returned.
Parameters:
Name Type Description objReturns:
- Type
- baja.Facets
-
<static> make(keys [, values])
-
Make a
Facetsobject. This function can either take twoArrayobjects
for keys and values, twoFacetsor two object literals. In the latter two
cases, a newFacetsobject will be returned containing a combination of
keys and values from both inputFacetsobjects. If a key exists on both
Facetsobjects, the value from the second Facets will take precedence.Parameters:
Name Type Argument Description keysArray.<String> | baja.Facets | Object an array of keys for the
facets. The keys must beStrings. (This may also be aFacets(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).valuesArray.<baja.Simple> | baja.Facets | Object <optional>
an array of values
for the facets. The values must be BajaScript Objects whoseType
implementsBIDataValue. (This may also be aFacets(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
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 -
<static> mergeSlotFacets( [container] [, propertyPath])
-
Get the slot facets from a container, merged all the way down through a
property path or slot.Parameters:
Name Type Argument Description containerbaja.Complex <optional>
propertyPathArray.<(baja.Property|string)> | baja.Property | string <optional>
- Since:
-
- Niagara 4.10
Returns:
- Type
- baja.Facets
-
decodeAsync(str [, batch])
-
Decode a
Stringto aFacets, doing an async decode on each individual
encoded Simple.Parameters:
Name Type Argument Description strString batchbaja.comm.Batch <optional>
- Overrides:
Returns:
- Type
- Promise.<baja.Facets>
-
encodeToString()
-
Encode
Facetsto aString.- Overrides:
Returns:
- Type
- String
-
equals(obj)
-
Equality test.
Parameters:
Name Type Description obj- Inherited From:
Returns:
- Type
- Boolean
-
equivalent(obj)
-
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.Parameters:
Name Type Description obj- Inherited From:
Returns:
- Type
- Boolean
-
get(key [, def])
-
Return a value from the map for the given key.
Parameters:
Name Type Argument Description keyString 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( [is] [, batch])
-
Returns a promise that resolves to the agent list for this Object.
Parameters:
Name Type Argument Description isArray.<String> <optional>
An optional array of filters to add to the
agent query.batchbaja.comm.Batch <optional>
An optional object used to batch network
calls together.- Inherited From:
- See:
Returns:
A promise that will resolve with the Agent Info.
- Type
- Promise
-
getIcon()
-
Return the Object's Icon.
- Inherited From:
Returns:
- Type
- baja.Icon
-
getKeys()
-
Return a copy of the
Facetskeys.Returns:
all of the keys used in the
Facets- Type
- Array.<String>
-
getType()
-
Get the type of this instance.
- Inherited From:
Returns:
- Type
- Type
-
getTypeDisplayName( [cx])
-
Gets the friendly type display name for this object.
Parameters:
Name Type Argument Description cxObject <optional>
a context to be passed down to Type
- Since:
-
- Niagara 4.10
- Inherited From:
- See:
-
- baja.Type#getDisplayName
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()
-
Make a
Facetsobject. Same as baja.Facets.make.- Overrides:
- See:
-
newCopy( [exact])
-
Every value may be cloned using the
newCopymethod.Please note that
Simples are immutable so they don't
allocate a new instance.Parameters:
Name Type Argument Description exactBoolean <optional>
true if an exact copy of the value should be
made (only valid in the Component architecture).- Inherited From:
- See:
Returns:
a copy of the value (or the same instance if the value is a
Simple). -
toObject()
-
Converts the
Facets(itself) to an object literal.Returns:
- Type
- Object
-
toString( [cx])
-
Return a
Stringrepresentation of theFacets.Parameters:
Name Type Argument Description cxObject <optional>
Passed directly into the toString() functions of the
individual Simples within. Object Literal used to specify formatting
facets.- Overrides:
Returns:
returns a Promise if a cx is passed in.
-
valueOf()
-
Return the value of the
Facets.- Overrides:
Returns:
- Type
- String