Target filter
Search Kotlin docs
  • Platforms
  • Tealium Prism Kotlin
core/com.tealium.prism.core.api.data/DataObject

DataObject

class DataObject : Iterable<Map.Entry<String, DataItem>> , DataItemConvertible, DataItemExtractor

The DataObject represents a map of restricted data types which are wrappable by DataItem, to ensure that all data passed to the SDK can be used correctly and without unexpected behaviours when converting to Strings.

Instances of DataObject are immutable. When requiring updates, the copy method is available to use, which is prepopulate a Builder with the existing set of DataItems

This class will serialize to a JSON object - { ... } - when calling toString.

See also

DataItem
DataList

Types

Builder
Link copied to clipboard
class Builder @JvmOverloads constructor(copy: DataObject = EMPTY_OBJECT)
Companion
Link copied to clipboard
object Companion
Converter
Link copied to clipboard
object Converter : DataItemConverter<DataObject>

Properties

size
Link copied to clipboard
val size: Int

Returns the number of top level entries stored in this DataObject.

Functions

asDataItem
Link copied to clipboard
open override fun asDataItem(): DataItem

Should return an instance of a DataItem that represents all required properties of the implementing class, such that it could be:

asParcelable
Link copied to clipboard
fun DataObject.asParcelable(): ParcelableDataItem

Returns a ParcelableDataItem that wraps the DataItem.

buildPath
Link copied to clipboard
fun buildPath(path: JsonObjectPath, item: DataItem): DataObject

Takes a copy of this DataObject and builds the necessary path according to the given path in order to store the given item.

buildUpon
Link copied to clipboard
fun buildUpon(): DataObject.Builder

Convenience method to create a new Builder containing all the values in this DataObject

copy
Link copied to clipboard
inline fun copy(block: DataObject.Builder.() -> Unit = {}): DataObject

Copies the existing DataObject into a new Builder instance that can be used to add/remove entries and create a new instance of the DataObject

equals
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
extract
Link copied to clipboard
open override fun extract(jsonPath: JsonPath<JsonPath.Component.Key>): DataItem?

Extracts a nested DataItem according to the given jsonPath.

open fun <T> extract(jsonPath: JsonPath<JsonPath.Component.Key>, converter: DataItemConverter<T>): T?

Extracts a nested DataItem according to the given jsonPath, and attempts to convert it to the type T using the given converter

extractBoolean
Link copied to clipboard
open fun extractBoolean(jsonPath: JsonPath<JsonPath.Component.Key>): Boolean?

Extracts a nested Boolean according to the given jsonPath.

extractDataList
Link copied to clipboard
open fun extractDataList(jsonPath: JsonPath<JsonPath.Component.Key>): DataList?

Extracts a nested DataList according to the given jsonPath.

extractDataObject
Link copied to clipboard
open fun extractDataObject(jsonPath: JsonPath<JsonPath.Component.Key>): DataObject?

Extracts a nested DataObject according to the given jsonPath.

extractDouble
Link copied to clipboard
open fun extractDouble(jsonPath: JsonPath<JsonPath.Component.Key>): Double?

Extracts a nested Double according to the given jsonPath.

extractInt
Link copied to clipboard
open fun extractInt(jsonPath: JsonPath<JsonPath.Component.Key>): Int?

Extracts a nested Int according to the given jsonPath.

extractLong
Link copied to clipboard
open fun extractLong(jsonPath: JsonPath<JsonPath.Component.Key>): Long?

Extracts a nested Long according to the given jsonPath.

extractString
Link copied to clipboard
open fun extractString(jsonPath: JsonPath<JsonPath.Component.Key>): String?

Extracts a nested String according to the given jsonPath.

get
Link copied to clipboard
open fun <T> get(key: String, converter: DataItemConverter<T>): T?

Gets the DataItem stored at the given key if there is one, and uses the given converter to translate it into an instance of type T

open override fun get(key: String): DataItem?

Gets the DataItem stored at the given key if it exists regardless of it's underlying type.

getAll
Link copied to clipboard
fun getAll(): Map<String, DataItem>

Returns all entries stored in the DataObject

getBoolean
Link copied to clipboard
open fun getBoolean(key: String): Boolean?

Gets the Boolean stored at the given key if there is one

getDataList
Link copied to clipboard
open fun getDataList(key: String): DataList?

Gets the DataList stored at the given key if there is one

getDataObject
Link copied to clipboard
open fun getDataObject(key: String): DataObject?

Gets the DataObject stored at the given key if there is one

getDouble
Link copied to clipboard
open fun getDouble(key: String): Double?

Gets the Double stored at the given key if there is one

getInt
Link copied to clipboard
open fun getInt(key: String): Int?

Gets the Int stored at the given key if there is one

getLong
Link copied to clipboard
open fun getLong(key: String): Long?

Gets the Long stored at the given key if there is one

getString
Link copied to clipboard
open fun getString(key: String): String?

Gets the String stored at the given key if there is one

hashCode
Link copied to clipboard
open override fun hashCode(): Int
iterator
Link copied to clipboard
open operator override fun iterator(): Iterator<Map.Entry<String, DataItem>>

Returns the Iterator in order to iterate over the collection.

mapValues
Link copied to clipboard
inline fun <T> DataObject.mapValues(transform: (DataItem) -> T): Map<String, T>

Maps the Map.Entry.value component only, keeping the Map.Entry.key the same.

mapValuesNotNull
Link copied to clipboard
inline fun <T> DataObject.mapValuesNotNull(transform: (DataItem) -> T?): Map<String, T>

Maps the Map.Entry.value component only, keeping the Map.Entry.key the same.

merge
Link copied to clipboard
@JvmOverloads
fun merge(other: DataObject, depth: Int = Int.MAX_VALUE): DataObject

Deep merges two DataObjects together, returning a new DataObject containing the merged data.

merge
Link copied to clipboard
fun <T> Iterable<Observable<T>>.merge(): Observable<T>

Convenience method for merging a Iterable group of Observables of the same type.

plus
Link copied to clipboard
operator fun DataObject.plus(other: DataObject): DataObject

Merges two DataObject objects together.

toString
Link copied to clipboard
open override fun toString(): String
Generated by Dokka
(c) Tealium 2026