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(Constructs a |
Builder(Constructs a |
Builder(Constructs a |
Builder(Constructs a |
Public constructors
Builder
public Builder(
@NonNull AppFunctionAllOfTypeMetadata allOfTypeMetadata,
@NonNull AppFunctionComponentsMetadata componentMetadata
)
Constructs a Builder to create AppFunctionData representing an all-of object.
The caller can use this to construct the AppFunctionData that conforms with the provided allOfTypeMetadata.
| Parameters | |
|---|---|
@NonNull AppFunctionAllOfTypeMetadata allOfTypeMetadata |
|
@NonNull AppFunctionComponentsMetadata componentMetadata |
|
Builder
public Builder(
@NonNull AppFunctionObjectTypeMetadata objectTypeMetadata,
@NonNull AppFunctionComponentsMetadata componentMetadata
)
Constructs a Builder to create AppFunctionData representing an object.
The caller can use this to construct the AppFunctionData that conforms with the provided objectTypeMetadata.
| Parameters | |
|---|---|
@NonNull AppFunctionObjectTypeMetadata objectTypeMetadata |
|
@NonNull AppFunctionComponentsMetadata componentMetadata |
|
Builder
public Builder(
@NonNull List<@NonNull AppFunctionParameterMetadata> parameterMetadataList,
@NonNull AppFunctionComponentsMetadata componentMetadata
)
Constructs a Builder to create input data for an AppFunction execution call.
The caller can use this to construct the AppFunctionData for ExecuteAppFunctionRequest.functionParameters.
| Parameters | |
|---|---|
@NonNull List<@NonNull AppFunctionParameterMetadata> parameterMetadataList |
List of |
@NonNull AppFunctionComponentsMetadata componentMetadata |
|
Builder
public Builder(
@NonNull AppFunctionResponseMetadata responseMetadata,
@NonNull AppFunctionComponentsMetadata componentMetadata
)
Constructs a Builder to create AppFunctionData representing a response.
The caller can use this to construct the AppFunctionData for ExecuteAppFunctionResponse.Success.returnValue.
| Parameters | |
|---|---|
@NonNull AppFunctionResponseMetadata responseMetadata |
|
@NonNull AppFunctionComponentsMetadata componentMetadata |
|
Public methods
build
public final @NonNull AppFunctionData build()
Builds AppFunctionData
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if any required property, as defined by the metadata specification, is missing. |
setAppFunctionData
@CanIgnoreReturnValue
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 |
@NonNull AppFunctionData value |
The |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
setAppFunctionDataList
@CanIgnoreReturnValue
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 |
@NonNull List<@NonNull AppFunctionData> value |
The |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
setBoolean
@CanIgnoreReturnValue
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 |
The |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
setBooleanArray
@CanIgnoreReturnValue
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 |
@NonNull boolean[] value |
The |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
setByteArray
@CanIgnoreReturnValue
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 |
@NonNull byte[] value |
The |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
setDouble
@CanIgnoreReturnValue
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 |
The |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
setDoubleArray
@CanIgnoreReturnValue
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 |
@NonNull double[] value |
The |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
setFloat
@CanIgnoreReturnValue
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 |
The |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
setFloatArray
@CanIgnoreReturnValue
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 |
@NonNull float[] value |
The |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
setInt
@CanIgnoreReturnValue
public final @NonNull AppFunctionData.Builder setInt(@NonNull String key, int value)
Sets an Int value for the given key.
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
setIntArray
@CanIgnoreReturnValue
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 |
@NonNull int[] value |
The |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
setLong
@CanIgnoreReturnValue
public final @NonNull AppFunctionData.Builder setLong(@NonNull String key, long value)
Sets a Long value for the given key.
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
setLongArray
@CanIgnoreReturnValue
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 |
@NonNull long[] value |
The |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
setParcelable
@CanIgnoreReturnValue
public final @NonNull AppFunctionData.Builder <T extends Parcelable> setParcelable(@NonNull String key, @NonNull T value)
Sets a Parcelable value of type T for the given key.
For Parcelable types not defined by the Android platform (e.g., custom classes shared between agents and apps), forward and backward compatibility is not guaranteed by this library. The sender and receiver of the Parcelable are responsible for managing any compatibility and versioning concerns.
| Parameters | |
|---|---|
@NonNull String key |
The key to set the value for. |
@NonNull T value |
The |
setParcelableList
@CanIgnoreReturnValue
public final @NonNull AppFunctionData.Builder <T extends Parcelable> setParcelableList(
@NonNull String key,
@NonNull List<@NonNull T> value
)
Sets a List of Parcelable values of type T for the given key.
For Parcelable types not defined by the Android platform (e.g., custom classes shared between agents and apps), forward and backward compatibility is not guaranteed by this framework. The sender and receiver of the Parcelable are responsible for managing any compatibility and versioning concerns.
setPendingIntent
@CanIgnoreReturnValue
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 |
@NonNull PendingIntent value |
The |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
setPendingIntentList
@CanIgnoreReturnValue
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 |
@NonNull List<@NonNull PendingIntent> value |
The |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
setString
@CanIgnoreReturnValue
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 |
@NonNull String value |
The |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
setStringList
@CanIgnoreReturnValue
public final @NonNull AppFunctionData.Builder setStringList(@NonNull String key, @NonNull List<@NonNull String> value)
Sets a List of String value for the given key.
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |