utils

Namespace

utils

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

Source:

Members

(static) OPENHAB_JS_VERSION :string

Description:
  • openHAB JavaScript library version

Source:

openHAB JavaScript library version

Type:
  • string

Methods

(static) dumpObject(obj, dumpPropsopt)

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

Source:
Parameters:
Name Type Attributes Default Description
obj *

object

dumpProps boolean <optional>
false

whether properties also should be dumped

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

Description:
  • Checks whether an object is instance of a Java class.

Source:
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}

Description:
  • Convert Java Instant to JS-Joda Instant.

Source:
Parameters:
Name Type Description
instant JavaInstant

java.time.Instant

Returns:
Type
time.Instant

(static) javaListToJsArray(list) → {Array}

Description:
  • Convert Java List to JavaScript Array.

Source:
Parameters:
Name Type Description
list JavaList
Returns:

JavaScript Array

Type
Array

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

Description:
  • Convert Java Map to JavaScript Map.

Source:
Parameters:
Name Type Description
map JavaMap
Returns:

JavaScript Map

Type
Map:.<any:, any:>

(static) javaMapToJsObj(map) → {object}

Description:
  • Convert Java Map to JavaScript Object.

Source:
Parameters:
Name Type Description
map JavaMap
Returns:

JavaScript Object

Type
object

(static) javaSetToJsArray(set) → {Array}

Description:
  • Convert Java Set to JavaScript Array.

Source:
Parameters:
Name Type Description
set JavaSet
Returns:

JavaScript Array

Type
Array

(static) javaSetToJsSet(set) → {Set}

Description:
  • Convert Java Set to JavaScript Set.

Source:
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}

Description:
  • Convert Java ZonedDateTime to JS-Joda ZonedDateTime.

Source:
Parameters:
Name Type Description
zdt JavaZonedDateTime

java.time.ZonedDateTime

Returns:
Type
time.ZonedDateTime

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

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

Source:
Parameters:
Name Type Description
zdt JavaZonedDateTime

java.time.ZonedDateTime

Returns:
Type
time.ZonedDateTime

(static) jsArrayToJavaList(arr) → {JavaList}

Description:
  • Convert JavaScript Array to Java List.

Source:
Parameters:
Name Type Description
arr Array

JavaScript Array

Returns:
Type
JavaList

(static) jsArrayToJavaSet(arr) → {JavaSet}

Description:
  • Convert JavaScript Array to Java Set.

Source:
Parameters:
Name Type Description
arr Array
Returns:

Java Set

Type
JavaSet

(static) jsSetToJavaSet(set) → {JavaSet}

Description:
  • Convert JavaScript Set to Java Set.

Source:
Parameters:
Name Type Description
set Set

JavaScript Set

Returns:

Java Set

Type
JavaSet

(static) randomUUID() → {string}

Description:
  • Generate a random UUID.

Source:
Returns:

random UUID

Type
string