utils

utils

Source:

Utils namespace. This namespace handles utilities, especially for conversion from and to Java data types.

Members

(static) OPENHAB_JS_VERSION :string

Source:

openHAB JavaScript library version

Type:
  • string

Methods

(static) dumpObject(obj, dumpPropsopt)

Source:

Outputs all members and properties of an object and whether it is a JS or a Java Object to the log.

Parameters:
Name Type Attributes Default Description
obj *

object

dumpProps boolean <optional>
false

whether properties also should be dumped

(static) isJsInstanceOfJavaType(instance, type) → {boolean}

Source:

Checks whether an object is instance of a Java class.

Parameters:
Name Type Description
instance *

object

type JavaClass

Java class (https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Class.html)

Throws:

error if type is not a java class

Returns:

whether it is an instance of a Java class

Type
boolean

(static) javaInstantToJsInstant(instant) → {time.Instant}

Source:

Convert Java Instant to JS-Joda Instant.

Parameters:
Name Type Description
instant JavaInstant

java.time.Instant

Returns:
Type
time.Instant

(static) javaListToJsArray(list) → {Array}

Source:

Convert Java List to JavaScript Array.

Parameters:
Name Type Description
list JavaList
Returns:

JavaScript Array

Type
Array

(static) javaMapToJsMap(map) → {Map.<any, any>}

Source:

Convert Java Map to JavaScript Map.

Parameters:
Name Type Description
map JavaMap
Returns:

JavaScript Map

Type
Map.<any, any>

(static) javaMapToJsObj(map) → {object}

Source:

Convert Java Map to JavaScript Object.

Parameters:
Name Type Description
map JavaMap
Returns:

JavaScript Object

Type
object

(static) javaSetToJsArray(set) → {Array}

Source:

Convert Java Set to JavaScript Array.

Parameters:
Name Type Description
set JavaSet
Returns:

JavaScript Array

Type
Array

(static) javaSetToJsSet(set) → {Set}

Source:

Convert Java Set to JavaScript Set.

Parameters:
Name Type Description
set JavaSet

Java Set (https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Set.html)

Returns:
Type
Set

(static) javaZDTToJsZDT(zdt) → {time.ZonedDateTime}

Source:

Convert Java ZonedDateTime to JS-Joda ZonedDateTime.

Parameters:
Name Type Description
zdt JavaZonedDateTime

java.time.ZonedDateTime

Returns:
Type
time.ZonedDateTime

(static) javaZDTToJsZDTWithDefaultZoneSystem(zdt) → {time.ZonedDateTime}

Source:

Convert Java ZonedDateTime to JS-Joda ZonedDateTime and default to SYSTEM timezone if not explicitly set.

Parameters:
Name Type Description
zdt JavaZonedDateTime

java.time.ZonedDateTime

Returns:
Type
time.ZonedDateTime

(static) jsArrayToJavaList(arr) → {JavaList}

Source:

Convert JavaScript Array to Java List.

Parameters:
Name Type Description
arr Array

JavaScript Array

Returns:
Type
JavaList

(static) jsArrayToJavaSet(arr) → {JavaSet}

Source:

Convert JavaScript Array to Java Set.

Parameters:
Name Type Description
arr Array
Returns:

Java Set

Type
JavaSet

(static) jsSetToJavaSet(set) → {JavaSet}

Source:

Convert JavaScript Set to Java Set.

Parameters:
Name Type Description
set Set

JavaScript Set

Returns:

Java Set

Type
JavaSet

(static) randomUUID() → {string}

Source:

Generate a random UUID.

Returns:

random UUID

Type
string