AppFunctionData


@RequiresApi(value = 33)
public final 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

public final class AppFunctionData.Builder

Builder for constructing AppFunctionData

Public fields

static final @NonNull AppFunctionData

Represents an empty AppFunctionData.

Public methods

final boolean

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

final @NonNull T
<T extends Object> deserialize(@NonNull Class<@NonNull T> serializableClass)

Deserializes the AppFunctionData to an AppFunctionSerializable instance.

final AppFunctionData

Retrieves an AppFunctionData value associated with the specified key.

final List<@NonNull AppFunctionData>

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

final boolean

Retrieves a Boolean value associated with the specified key.

final boolean
getBoolean(@NonNull String key, boolean defaultValue)

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

final boolean[]

Retrieves a BooleanArray value associated with the specified key.

final byte[]

Retrieves a ByteArray value associated with the specified key.

final double

Retrieves a Double value associated with the specified key.

final double
getDouble(@NonNull String key, double defaultValue)

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

final double[]

Retrieves a DoubleArray value associated with the specified key.

final float

Retrieves a Float value associated with the specified key.

final float
getFloat(@NonNull String key, float defaultValue)

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

final float[]

Retrieves a FloatArray value associated with the specified key.

final int

Retrieves an Int value associated with the specified key.

final int
getInt(@NonNull String key, int defaultValue)

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

final int[]

Retrieves an IntArray value associated with the specified key.

final long

Retrieves a Long value associated with the specified key.

final long
getLong(@NonNull String key, long defaultValue)

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

final long[]

Retrieves a LongArray value associated with the specified key.

final PendingIntent

Retrieves a PendingIntent value associated with the specified key.

final List<@NonNull PendingIntent>

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

final @NonNull String

Qualified name of the underlying object

final String

Retrieves a String value associated with the specified key.

final List<@NonNull String>

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

static final @NonNull AppFunctionData
<T extends Object> serialize(
    @NonNull T serializable,
    @NonNull Class<@NonNull T> serializableClass
)

Serializes serializable to an AppFunctionData.

@NonNull String

Public fields

EMPTY

public static final @NonNull AppFunctionData EMPTY

Represents an empty AppFunctionData.

Public methods

containsKey

Added in 1.0.0-alpha01
public final boolean containsKey(@NonNull String key)

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

Parameters
@NonNull String key

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
public final @NonNull T <T extends Object> deserialize(@NonNull Class<@NonNull T> serializableClass)

Deserializes the AppFunctionData to an AppFunctionSerializable instance.

Parameters
@NonNull Class<@NonNull T> serializableClass

The AppFunctionSerializable class.

Returns
@NonNull 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
public final AppFunctionData getAppFunctionData(@NonNull String key)

Retrieves an AppFunctionData value associated with the specified key.

Parameters
@NonNull String key

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
public final List<@NonNull AppFunctionDatagetAppFunctionDataList(@NonNull String key)

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

Parameters
@NonNull String key

The key to retrieve the value for.

Returns
List<@NonNull 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
public final boolean getBoolean(@NonNull String key)

Retrieves a Boolean value associated with the specified key.

Parameters
@NonNull String key

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
public final boolean getBoolean(@NonNull String key, boolean defaultValue)

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

Parameters
@NonNull String key

The key to retrieve the value for.

boolean defaultValue

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
public final boolean[] getBooleanArray(@NonNull String key)

Retrieves a BooleanArray value associated with the specified key.

Parameters
@NonNull String key

The key to retrieve the value for.

Returns
boolean[]

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
public final byte[] getByteArray(@NonNull String key)

Retrieves a ByteArray value associated with the specified key.

Parameters
@NonNull String key

The key to retrieve the value for.

Returns
byte[]

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
public final double getDouble(@NonNull String key)

Retrieves a Double value associated with the specified key.

Parameters
@NonNull String key

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
public final double getDouble(@NonNull String key, double defaultValue)

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

Parameters
@NonNull String key

The key to retrieve the value for.

double defaultValue

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
public final double[] getDoubleArray(@NonNull String key)

Retrieves a DoubleArray value associated with the specified key.

Parameters
@NonNull String key

The key to retrieve the value for.

Returns
double[]

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
public final float getFloat(@NonNull String key)

Retrieves a Float value associated with the specified key.

Parameters
@NonNull String key

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
public final float getFloat(@NonNull String key, float defaultValue)

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

Parameters
@NonNull String key

The key to retrieve the value for.

float defaultValue

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
public final float[] getFloatArray(@NonNull String key)

Retrieves a FloatArray value associated with the specified key.

Parameters
@NonNull String key

The key to retrieve the value for.

Returns
float[]

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
public final int getInt(@NonNull String key)

Retrieves an Int value associated with the specified key.

Parameters
@NonNull String key

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
public final int getInt(@NonNull String key, int defaultValue)

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

Parameters
@NonNull String key

The key to retrieve the value for.

int defaultValue

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
public final int[] getIntArray(@NonNull String key)

Retrieves an IntArray value associated with the specified key.

Parameters
@NonNull String key

The key to retrieve the value for.

Returns
int[]

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
public final long getLong(@NonNull String key)

Retrieves a Long value associated with the specified key.

Parameters
@NonNull String key

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
public final long getLong(@NonNull String key, long defaultValue)

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

Parameters
@NonNull String key

The key to retrieve the value for.

long defaultValue

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
public final long[] getLongArray(@NonNull String key)

Retrieves a LongArray value associated with the specified key.

Parameters
@NonNull String key

The key to retrieve the value for.

Returns
long[]

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
public final PendingIntent getPendingIntent(@NonNull String key)

Retrieves a PendingIntent value associated with the specified key.

Parameters
@NonNull String key

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
public final List<@NonNull PendingIntentgetPendingIntentList(@NonNull String key)

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

Parameters
@NonNull String key

The key to retrieve the value for.

Returns
List<@NonNull 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.

getQualifiedName

Added in 1.0.0-alpha01
public final @NonNull String getQualifiedName()

Qualified name of the underlying object

getString

Added in 1.0.0-alpha01
public final String getString(@NonNull String key)

Retrieves a String value associated with the specified key.

Parameters
@NonNull String key

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
public final List<@NonNull StringgetStringList(@NonNull String key)

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

Parameters
@NonNull String key

The key to retrieve the value for.

Returns
List<@NonNull 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.

serialize

Added in 1.0.0-alpha01
public static final @NonNull AppFunctionData <T extends Object> serialize(
    @NonNull T serializable,
    @NonNull Class<@NonNull T> serializableClass
)

Serializes serializable to an AppFunctionData.

Parameters
@NonNull T serializable

The instance of serializableClass.

@NonNull Class<@NonNull T> serializableClass

The class of serializable.

Returns
@NonNull AppFunctionData

AppFunctionData with properties from serializable.

Throws
kotlin.IllegalArgumentException

If unable to serialize serializable to an AppFunctionData.

toString

public @NonNull String toString()