AppFunctionIntValueConstraint
@Retention(value = AnnotationRetention.BINARY)
@Target(allowedTargets = [AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.VALUE_PARAMETER])
public annotation AppFunctionIntValueConstraint
Specifies constraints applied on the integer values for return types, parameters, or properties in app functions.
This annotation can be applied to:
-
functions annotated with
@AppFunction(to constrain the return value), -
parameters of
@AppFunction, -
or properties within an
@AppFunctionSerializable.
Usage Example:
// Constraining a function return value:
@AppFunction
@AppFunctionIntValueConstraint(enumValues = [0, 1, 2])
fun getDisplayMode(): Int {
// Function body
}
// Constraining a parameter:
@AppFunction
fun adjustVolume(
@AppFunctionIntValueConstraint(enumValues = [10, 15, 20, 25])
volumeLevel: Int
) {
// Function body
}
// Constraining a property within an AppFunctionSerializable:
@AppFunctionSerializable
data class MySettings(
@property:AppFunctionIntValueConstraint(enumValues = [0, 1])
val darkMode: Int
)
Summary
Public constructors
AppFunctionIntValueConstraint
public AppFunctionIntValueConstraint(@NonNull int[] enumValues)
Public methods
getEnumValues
public final @NonNull int[] getEnumValues()
The list of allowed integer values for the annotated element.
These values are communicated to the agent or framework that interprets or invokes the @AppFunction. If any of the values carry special meaning (e.g., 0 means "off", 1 means "on"), such meanings should be documented clearly in the corresponding property, parameter, or function return KDoc.
