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

DataItem

class DataItem : DataItemConvertible

Immutable data class for restricting the supported types that can be passed into the system.

The toString() method will provide a JSON friendly representation of the data enclosed. That is,

  • String data will be quoted; i.e. "my string"

  • Numeric data will not be quoted; i.e. 10 or 3.141..

  • Boolean data will not be quoted; i.e. true/false

  • DataList data will be formatted as a JSON Array; i.e. ["value", 10, true]

  • DataObject data will be formatted as a JSON Object; i.e. { "key":"value", "number":10 }

This class is currently broadly similar to the JSONObject and makes use of several methods provided by the org.json package on Android.

The any value should be restricted to only JSON supportable types - see convert.

The string parameter should only be used in the case where this value is being lazily instantiated from an already stringified representation of the value. If provided, then the string parameter will be used as the pre-computed return value from toString as well

Parameters

any

The value to be wrapped; at least this or the string value need to be provided

string

The string value representing the value of any; at least this or the string value need to be provided

Types

Companion
Link copied to clipboard
object Companion

Properties

value
Link copied to clipboard
val value: Any?

Contains the underlying data value for this instance.

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 DataItem.asParcelable(): ParcelableDataItem

Returns a ParcelableDataItem that wraps the DataItem.

equals
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
getBoolean
Link copied to clipboard
fun getBoolean(): Boolean?

Returns the contained value as an Boolean if the contained value is a Boolean.

getDataList
Link copied to clipboard
fun getDataList(): DataList?

Returns the contained value as an DataList if the contained value is a DataList.

getDataObject
Link copied to clipboard
fun getDataObject(): DataObject?

Returns the contained value as an DataObject if the contained value is a DataObject.

getDouble
Link copied to clipboard
fun getDouble(): Double?

Returns the contained value as an Double if the contained value is a Double, or a Number that can be coerced to an Double.

getInt
Link copied to clipboard
fun getInt(): Int?

Returns the contained value as an Int if the contained value is an Int, or a Number that can be coerced to an Int.

getLong
Link copied to clipboard
fun getLong(): Long?

Returns the contained value as an Long if the contained value is a Long, or a Number that can be coerced to an Long.

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

Returns the contained value as a String if the contained value is a String.

hashCode
Link copied to clipboard
open override fun hashCode(): Int
isBoolean
Link copied to clipboard
fun isBoolean(): Boolean

Indicates whether the contained value is a Boolean

isDataList
Link copied to clipboard
fun isDataList(): Boolean

Indicates whether the contained value is a DataList

isDataObject
Link copied to clipboard
fun isDataObject(): Boolean

Indicates whether the contained value is a DataObject

isDouble
Link copied to clipboard
fun isDouble(): Boolean

Indicates whether the contained value is a Double

isInt
Link copied to clipboard
fun isInt(): Boolean

Indicates whether the contained value is an Int

isLong
Link copied to clipboard
fun isLong(): Boolean

Indicates whether the contained value is a Long

isNull
Link copied to clipboard
fun isNull(): Boolean

Indicates whether the contained value is null

isNumber
Link copied to clipboard
fun isNumber(): Boolean

Indicates whether the contained value is a Number

isString
Link copied to clipboard
fun isString(): Boolean

Indicates whether the contained value is a String

toString
Link copied to clipboard
open override fun toString(): String

Returns the String representation of the value in a JSON compliant format.

Generated by Dokka
(c) Tealium 2026