AppFunctionData.Builder


public final class AppFunctionData.Builder


Builder for constructing AppFunctionData

For example, to write an AppFunctionData for calling an AppFunction

fun callCreateNoteFunction(metadata: AppFunctionMetadata) {
val appFunctionData = AppFunctionData.Builder(
metadata.parameters,
metadata.components,
).apply {
setString("title", "Note Title")
// If the function doesn't accept "owner" as parameter, it would throw an error
setString("owner", "Me")
// If the function actually expects "content" as String, it would throw an error
setInt("content", 100)
}
.build()
}

Summary

Public constructors

Builder(
    @NonNull AppFunctionObjectTypeMetadata objectTypeMetadata,
    @NonNull AppFunctionComponentsMetadata componentMetadata
)

Constructs a Builder to create AppFunctionData representing an object.

Builder(
    @NonNull List<@NonNull AppFunctionParameterMetadata> parameterMetadataList,
    @NonNull AppFunctionComponentsMetadata componentMetadata
)

Constructs a Builder to create input data for an AppFunction execution call.

Public methods

final @NonNull AppFunctionData

Builds AppFunctionData

final @NonNull AppFunctionData.Builder

Sets an AppFunctionData value for the given key.

final @NonNull AppFunctionData.Builder

Sets a List of AppFunctionData value for the given key.

final @NonNull AppFunctionData.Builder
setBoolean(@NonNull String key, boolean value)

Sets a Boolean value for the given key.

final @NonNull AppFunctionData.Builder
setBooleanArray(@NonNull String key, @NonNull boolean[] value)

Sets a BooleanArray value for the given key.

final @NonNull AppFunctionData.Builder
setByteArray(@NonNull String key, @NonNull byte[] value)

Sets a ByteArray value for the given key.

final @NonNull AppFunctionData.Builder
setDouble(@NonNull String key, double value)

Sets a Double value for the given key.

final @NonNull AppFunctionData.Builder
setDoubleArray(@NonNull String key, @NonNull double[] value)

Sets a DoubleArray value for the given key.

final @NonNull AppFunctionData.Builder
setFloat(@NonNull String key, float value)

Sets a Float value for the given key.

final @NonNull AppFunctionData.Builder
setFloatArray(@NonNull String key, @NonNull float[] value)

Sets a FloatArray value for the given key.

final @NonNull AppFunctionData.Builder
setInt(@NonNull String key, int value)

Sets an Int value for the given key.

final @NonNull AppFunctionData.Builder
setIntArray(@NonNull String key, @NonNull int[] value)

Sets an IntArray value for the given key.

final @NonNull AppFunctionData.Builder
setLong(@NonNull String key, long value)

Sets a Long value for the given key.

final @NonNull AppFunctionData.Builder
setLongArray(@NonNull String key, @NonNull long[] value)

Sets a LongArray value for the given key.

final @NonNull AppFunctionData.Builder

Sets a PendingIntent value for the given key.

final @NonNull AppFunctionData.Builder

Sets a List of PendingIntent value for the given key.

final @NonNull AppFunctionData.Builder

Sets a String value for the given key.

final @NonNull AppFunctionData.Builder

Sets a List of String value for the given key.

Public constructors

Builder

Added in 1.0.0-alpha01
public Builder(
    @NonNull AppFunctionObjectTypeMetadata objectTypeMetadata,
    @NonNull AppFunctionComponentsMetadata componentMetadata
)

Constructs a Builder to create AppFunctionData representing an object.

This constructor is used when you need to create AppFunctionData that represents an object used as either function parameters or return values, as defined by an AppFunctionObjectTypeMetadata. This metadata specifies the properties and their types for the object.

Parameters
@NonNull AppFunctionObjectTypeMetadata objectTypeMetadata

AppFunctionObjectTypeMetadata defining the object structure.

@NonNull AppFunctionComponentsMetadata componentMetadata

AppFunctionComponentsMetadata that has the shared data type.

Builder

Added in 1.0.0-alpha01
public Builder(
    @NonNull List<@NonNull AppFunctionParameterMetadata> parameterMetadataList,
    @NonNull AppFunctionComponentsMetadata componentMetadata
)

Constructs a Builder to create input data for an AppFunction execution call.

This constructor is used when you need to write data that will be passed as input when executing an AppFunction. The parameterMetadataList defines the expected input parameters for that function.

Parameters
@NonNull List<@NonNull AppFunctionParameterMetadata> parameterMetadataList

List of AppFunctionParameterMetadata defining the input parameters.

@NonNull AppFunctionComponentsMetadata componentMetadata

AppFunctionComponentsMetadata that has the shared data type.

Public methods

build

Added in 1.0.0-alpha01
public final @NonNull AppFunctionData build()

Builds AppFunctionData

setAppFunctionData

Added in 1.0.0-alpha01
public final @NonNull AppFunctionData.Builder setAppFunctionData(@NonNull String key, @NonNull AppFunctionData value)

Sets an AppFunctionData value for the given key.

Parameters
@NonNull String key

The key to set the AppFunctionData value for.

@NonNull AppFunctionData value

The AppFunctionData value to set.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value does not match the metadata specification associated with the key.

setAppFunctionDataList

Added in 1.0.0-alpha01
public final @NonNull AppFunctionData.Builder setAppFunctionDataList(
    @NonNull String key,
    @NonNull List<@NonNull AppFunctionData> value
)

Sets a List of AppFunctionData value for the given key.

Parameters
@NonNull String key

The key to set the List of AppFunctionData value for.

@NonNull List<@NonNull AppFunctionData> value

The List of AppFunctionData value to set.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value does not match the metadata specification associated with the key.

setBoolean

Added in 1.0.0-alpha01
public final @NonNull AppFunctionData.Builder setBoolean(@NonNull String key, boolean value)

Sets a Boolean value for the given key.

Parameters
@NonNull String key

The key to set the Boolean value for.

boolean value

The Boolean value to set.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value does not match the metadata specification associated with the key.

setBooleanArray

Added in 1.0.0-alpha01
public final @NonNull AppFunctionData.Builder setBooleanArray(@NonNull String key, @NonNull boolean[] value)

Sets a BooleanArray value for the given key.

Parameters
@NonNull String key

The key to set the BooleanArray value for.

@NonNull boolean[] value

The BooleanArray value to set.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value does not match the metadata specification associated with the key.

setByteArray

Added in 1.0.0-alpha01
public final @NonNull AppFunctionData.Builder setByteArray(@NonNull String key, @NonNull byte[] value)

Sets a ByteArray value for the given key.

Parameters
@NonNull String key

The key to set the ByteArray value for.

@NonNull byte[] value

The ByteArray value to set.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value does not match the metadata specification associated with the key.

setDouble

Added in 1.0.0-alpha01
public final @NonNull AppFunctionData.Builder setDouble(@NonNull String key, double value)

Sets a Double value for the given key.

Parameters
@NonNull String key

The key to set the Double value for.

double value

The Double value to set.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value does not match the metadata specification associated with the key.

setDoubleArray

Added in 1.0.0-alpha01
public final @NonNull AppFunctionData.Builder setDoubleArray(@NonNull String key, @NonNull double[] value)

Sets a DoubleArray value for the given key.

Parameters
@NonNull String key

The key to set the DoubleArray value for.

@NonNull double[] value

The DoubleArray value to set.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value does not match the metadata specification associated with the key.

setFloat

Added in 1.0.0-alpha01
public final @NonNull AppFunctionData.Builder setFloat(@NonNull String key, float value)

Sets a Float value for the given key.

Parameters
@NonNull String key

The key to set the Float value for.

float value

The Float value to set.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value does not match the metadata specification associated with the key.

setFloatArray

Added in 1.0.0-alpha01
public final @NonNull AppFunctionData.Builder setFloatArray(@NonNull String key, @NonNull float[] value)

Sets a FloatArray value for the given key.

Parameters
@NonNull String key

The key to set the DoubleArray value for.

@NonNull float[] value

The FloatArray value to set.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value does not match the metadata specification associated with the key.

setInt

Added in 1.0.0-alpha01
public final @NonNull AppFunctionData.Builder setInt(@NonNull String key, int value)

Sets an Int value for the given key.

Parameters
@NonNull String key

The key to set the Int value for.

int value

The Int value to set.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value does not match the metadata specification associated with the key.

setIntArray

Added in 1.0.0-alpha01
public final @NonNull AppFunctionData.Builder setIntArray(@NonNull String key, @NonNull int[] value)

Sets an IntArray value for the given key.

Parameters
@NonNull String key

The key to set the IntArray value for.

@NonNull int[] value

The IntArray value to set.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value does not match the metadata specification associated with the key.

setLong

Added in 1.0.0-alpha01
public final @NonNull AppFunctionData.Builder setLong(@NonNull String key, long value)

Sets a Long value for the given key.

Parameters
@NonNull String key

The key to set the Long value for.

long value

The Long value to set.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value does not match the metadata specification associated with the key.

setLongArray

Added in 1.0.0-alpha01
public final @NonNull AppFunctionData.Builder setLongArray(@NonNull String key, @NonNull long[] value)

Sets a LongArray value for the given key.

Parameters
@NonNull String key

The key to set the LongArray value for.

@NonNull long[] value

The LongArray value to set.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value does not match the metadata specification associated with the key.

setPendingIntent

Added in 1.0.0-alpha01
public final @NonNull AppFunctionData.Builder setPendingIntent(@NonNull String key, @NonNull PendingIntent value)

Sets a PendingIntent value for the given key.

Parameters
@NonNull String key

The key to set the AppFunctionData value for.

@NonNull PendingIntent value

The AppFunctionData value to set.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value does not match the metadata specification associated with the key.

setPendingIntentList

Added in 1.0.0-alpha01
public final @NonNull AppFunctionData.Builder setPendingIntentList(
    @NonNull String key,
    @NonNull List<@NonNull PendingIntent> value
)

Sets a List of PendingIntent value for the given key.

Parameters
@NonNull String key

The key to set the List of AppFunctionData value for.

@NonNull List<@NonNull PendingIntent> value

The List of AppFunctionData value to set.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value does not match the metadata specification associated with the key.

setString

Added in 1.0.0-alpha01
public final @NonNull AppFunctionData.Builder setString(@NonNull String key, @NonNull String value)

Sets a String value for the given key.

Parameters
@NonNull String key

The key to set the String value for.

@NonNull String value

The String value to set.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value does not match the metadata specification associated with the key.

setStringList

Added in 1.0.0-alpha01
public final @NonNull AppFunctionData.Builder setStringList(@NonNull String key, @NonNull List<@NonNull String> value)

Sets a List of String value for the given key.

Parameters
@NonNull String key

The key to set the List of String value for.

@NonNull List<@NonNull String> value

The List of String value to set.

Throws
kotlin.IllegalArgumentException

if the key is not allowed or the value does not match the metadata specification associated with the key.