AppFunctionData


@RequiresApi(value = 33)
class AppFunctionData


A data class to contain information to be communicated between AppFunctions apps and agents.

This class can be logically viewed as a mapping from String keys to properties of various supported types, or arrays of supported types.

When trying to retrieve an associated value, AppFunctionData would validate the request against the predefined metadata specification provided from Builder.

For example,

fun callCreateNoteFunction(
metadata: AppFunctionMetadata,
request: ExecuteAppFunctionRequest,
)
{
val response = appFunctionManager.executeAppFunction(request)

if (metadata.response.valueType is AppFunctionObjectTypeMetadata) {
val returnData = response.returnValue.getAppFunctionData(
ExecuteAppFunctionResponse.Success.PROPERTY_RETURN_VALUE
)
val title = returnData.getString("title")
// Throws an error if "owner" doesn't exist according to the metadata
val owner = returnData.getString("owner")
// Throws an error if "content" is String.
val content = returnData.getInt("content")
}
}

Summary

Nested types

Builder for constructing AppFunctionData

Public companion functions

AppFunctionData
<T : Any> serialize(serializable: T, serializableClass: Class<T>)

Serializes serializable to an AppFunctionData.

Public companion properties

AppFunctionData

Represents an empty AppFunctionData.

Public functions

Boolean

Checks if AppFunctionData has an associated value with the specified key.

T
<T : Any> deserialize(serializableClass: Class<T>)

Deserializes the AppFunctionData to an AppFunctionSerializable instance.

AppFunctionData?

Retrieves an AppFunctionData value associated with the specified key.

List<AppFunctionData>?

Retrieves a List of AppFunctionData value associated with the specified key.

Boolean

Retrieves a Boolean value associated with the specified key.

Boolean
getBoolean(key: String, defaultValue: Boolean)

Retrieves a Boolean value associated with the specified key, or returns defaultValue if the associated value is not found.

BooleanArray?

Retrieves a BooleanArray value associated with the specified key.

ByteArray?

Retrieves a ByteArray value associated with the specified key.

Double

Retrieves a Double value associated with the specified key.

Double
getDouble(key: String, defaultValue: Double)

Retrieves a Double value associated with the specified key, or returns defaultValue if the associated value is not found.

DoubleArray?

Retrieves a DoubleArray value associated with the specified key.

Float

Retrieves a Float value associated with the specified key.

Float
getFloat(key: String, defaultValue: Float)

Retrieves a Float value associated with the specified key, or returns defaultValue if the associated value is not found.

FloatArray?

Retrieves a FloatArray value associated with the specified key.

Int
getInt(key: String)

Retrieves an Int value associated with the specified key.

Int
getInt(key: String, defaultValue: Int)

Retrieves an Int value associated with the specified key, or returns defaultValue if the associated value is not found.

IntArray?

Retrieves an IntArray value associated with the specified key.

Long

Retrieves a Long value associated with the specified key.

Long
getLong(key: String, defaultValue: Long)

Retrieves a Long value associated with the specified key, or returns defaultValue if the associated value is not found.

LongArray?

Retrieves a LongArray value associated with the specified key.

PendingIntent?

Retrieves a PendingIntent value associated with the specified key.

List<PendingIntent>?

Retrieves a List of PendingIntent value associated with the specified key.

String?

Retrieves a String value associated with the specified key.

List<String>?

Retrieves a List of String value associated with the specified key.

open String

Public properties

String

Qualified name of the underlying object

Public companion functions

serialize

Added in 1.0.0-alpha01
fun <T : Any> serialize(serializable: T, serializableClass: Class<T>): AppFunctionData

Serializes serializable to an AppFunctionData.

Parameters
serializable: T

The instance of serializableClass.

serializableClass: Class<T>

The class of serializable.

Returns
AppFunctionData

AppFunctionData with properties from serializable.

Throws
kotlin.IllegalArgumentException

If unable to serialize serializable to an AppFunctionData.

Public companion properties

EMPTY

val EMPTYAppFunctionData

Represents an empty AppFunctionData.

Public functions

containsKey

Added in 1.0.0-alpha01
fun containsKey(key: String): Boolean

Checks if AppFunctionData has an associated value with the specified key.

Parameters
key: String

The key to checks for.

Returns
Boolean

True if there is an associated value. Otherwise, false.

Throws
kotlin.IllegalArgumentException

If there is no metadata related to key.

deserialize

Added in 1.0.0-alpha01
fun <T : Any> deserialize(serializableClass: Class<T>): T

Deserializes the AppFunctionData to an AppFunctionSerializable instance.

Parameters
serializableClass: Class<T>

The AppFunctionSerializable class.

Returns
T

The instance of serializableClass.

Throws
kotlin.IllegalArgumentException

If unable to deserialize the AppFunctionData to an instance of serializableClass.

getAppFunctionData

Added in 1.0.0-alpha01
fun getAppFunctionData(key: String): AppFunctionData?

Retrieves an AppFunctionData value associated with the specified key.

Parameters
key: String

The key to retrieve the value for.

Returns
AppFunctionData?

The value associated with the key, or null if the associated value is not found.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value type is incorrect according to the metadata specification.

getAppFunctionDataList

Added in 1.0.0-alpha01
fun getAppFunctionDataList(key: String): List<AppFunctionData>?

Retrieves a List of AppFunctionData value associated with the specified key.

Parameters
key: String

The key to retrieve the value for.

Returns
List<AppFunctionData>?

The value associated with the key. Or null if the associated value is not found.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value type is incorrect according to the metadata specification.

getBoolean

Added in 1.0.0-alpha01
fun getBoolean(key: String): Boolean

Retrieves a Boolean value associated with the specified key.

Parameters
key: String

The key to retrieve the value for.

Returns
Boolean

The value associated with the key. It would return a default value false if the associated value is not found.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value type is incorrect according to the metadata specification.

getBoolean

Added in 1.0.0-alpha01
fun getBoolean(key: String, defaultValue: Boolean): Boolean

Retrieves a Boolean value associated with the specified key, or returns defaultValue if the associated value is not found.

Parameters
key: String

The key to retrieve the value for.

defaultValue: Boolean

The default value if the associated value is not found.

Returns
Boolean

The value associated with the key, or the defaultValue if the associated value is not required and it is not found.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value type is incorrect according to the metadata specification.

getBooleanArray

Added in 1.0.0-alpha01
fun getBooleanArray(key: String): BooleanArray?

Retrieves a BooleanArray value associated with the specified key.

Parameters
key: String

The key to retrieve the value for.

Returns
BooleanArray?

The value associated with the key. Or null if the associated value is not found.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value type is incorrect according to the metadata specification.

getByteArray

Added in 1.0.0-alpha01
fun getByteArray(key: String): ByteArray?

Retrieves a ByteArray value associated with the specified key.

Parameters
key: String

The key to retrieve the value for.

Returns
ByteArray?

The value associated with the key. Or null if the associated value is not found.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value type is incorrect according to the metadata specification.

getDouble

Added in 1.0.0-alpha01
fun getDouble(key: String): Double

Retrieves a Double value associated with the specified key.

Parameters
key: String

The key to retrieve the value for.

Returns
Double

The value associated with the key. It would return a default value 0.0 if the associated value is not found.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value type is incorrect according to the metadata specification.

getDouble

Added in 1.0.0-alpha01
fun getDouble(key: String, defaultValue: Double): Double

Retrieves a Double value associated with the specified key, or returns defaultValue if the associated value is not found.

Parameters
key: String

The key to retrieve the value for.

defaultValue: Double

The default value if the associated value is not found.

Returns
Double

The value associated with the key, or the defaultValue if the associated value is not found.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value type is incorrect according to the metadata specification.

getDoubleArray

Added in 1.0.0-alpha01
fun getDoubleArray(key: String): DoubleArray?

Retrieves a DoubleArray value associated with the specified key.

Parameters
key: String

The key to retrieve the value for.

Returns
DoubleArray?

The value associated with the key. Or null if the associated value is not found.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value type is incorrect according to the metadata specification.

getFloat

Added in 1.0.0-alpha01
fun getFloat(key: String): Float

Retrieves a Float value associated with the specified key.

Parameters
key: String

The key to retrieve the value for.

Returns
Float

The value associated with the key. It would return a default value 0.0 if the associated value is not found.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value type is incorrect according to the metadata specification.

getFloat

Added in 1.0.0-alpha01
fun getFloat(key: String, defaultValue: Float): Float

Retrieves a Float value associated with the specified key, or returns defaultValue if the associated value is not found.

Parameters
key: String

The key to retrieve the value for.

defaultValue: Float

The default value if the associated value is not found.

Returns
Float

The value associated with the key, or the defaultValue if the associated is not found.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value type is incorrect according to the metadata specification.

getFloatArray

Added in 1.0.0-alpha01
fun getFloatArray(key: String): FloatArray?

Retrieves a FloatArray value associated with the specified key.

Parameters
key: String

The key to retrieve the value for.

Returns
FloatArray?

The value associated with the key. Or null if the associated value is not found.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value type is incorrect according to the metadata specification.

getInt

Added in 1.0.0-alpha01
fun getInt(key: String): Int

Retrieves an Int value associated with the specified key.

Parameters
key: String

The key to retrieve the value for.

Returns
Int

The value associated with the key. It would return a default value 0L if the associated value is not found.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value type is incorrect according to the metadata specification.

getInt

Added in 1.0.0-alpha01
fun getInt(key: String, defaultValue: Int): Int

Retrieves an Int value associated with the specified key, or returns defaultValue if the associated value is not found.

Parameters
key: String

The key to retrieve the value for.

defaultValue: Int

The default value if the associated value is not found.

Returns
Int

The value associated with the key, or the defaultValue if the associated value is not found.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value type is incorrect according to the metadata specification.

getIntArray

Added in 1.0.0-alpha01
fun getIntArray(key: String): IntArray?

Retrieves an IntArray value associated with the specified key.

Parameters
key: String

The key to retrieve the value for.

Returns
IntArray?

The value associated with the key. Or null if the associated value is not found.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value type is incorrect according to the metadata specification.

getLong

Added in 1.0.0-alpha01
fun getLong(key: String): Long

Retrieves a Long value associated with the specified key.

Parameters
key: String

The key to retrieve the value for.

Returns
Long

The value associated with the key. It would return a default value 0L if the associated value is not found.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value type is incorrect according to the metadata specification.

getLong

Added in 1.0.0-alpha01
fun getLong(key: String, defaultValue: Long): Long

Retrieves a Long value associated with the specified key, or returns defaultValue if the associated value is not found.

Parameters
key: String

The key to retrieve the value for.

defaultValue: Long

The default value if the associated value is not found.

Returns
Long

The value associated with the key, or the defaultValue if the associated value is not found.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value type is incorrect according to the metadata specification.

getLongArray

Added in 1.0.0-alpha01
fun getLongArray(key: String): LongArray?

Retrieves a LongArray value associated with the specified key.

Parameters
key: String

The key to retrieve the value for.

Returns
LongArray?

The value associated with the key. Or null if the associated value is not found.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value type is incorrect according to the metadata specification.

getPendingIntent

Added in 1.0.0-alpha01
fun getPendingIntent(key: String): PendingIntent?

Retrieves a PendingIntent value associated with the specified key.

Parameters
key: String

The key to retrieve the value for.

Returns
PendingIntent?

The value associated with the key, or null if the associated value is not found.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value type is incorrect according to the metadata specification.

getPendingIntentList

Added in 1.0.0-alpha01
fun getPendingIntentList(key: String): List<PendingIntent>?

Retrieves a List of PendingIntent value associated with the specified key.

Parameters
key: String

The key to retrieve the value for.

Returns
List<PendingIntent>?

The value associated with the key. Or null if the associated value is not found.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value type is incorrect according to the metadata specification.

getString

Added in 1.0.0-alpha01
fun getString(key: String): String?

Retrieves a String value associated with the specified key.

Parameters
key: String

The key to retrieve the value for.

Returns
String?

The value associated with the key, or null if the associated value is not found.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value type is incorrect according to the metadata specification.

getStringList

Added in 1.0.0-alpha01
fun getStringList(key: String): List<String>?

Retrieves a List of String value associated with the specified key.

Parameters
key: String

The key to retrieve the value for.

Returns
List<String>?

The value associated with the key. Or null if the associated value is not found.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value type is incorrect according to the metadata specification.

toString

open fun toString(): String

Public properties

qualifiedName

Added in 1.0.0-alpha01
val qualifiedNameString

Qualified name of the underlying object