从操作返回值
在 CommandPkg 上设置以下属性,以将操作输出存储在变量中。
操作返回值
- return_type
- 定义操作的返回值类型。它通常匹配输入方法返回类型。
- return_required
- 设定为 true 后,返回值为必需。
- return_label
- 请求变量存储值时的 UI 标签。
@BotCommand
@CommandPkg(label = "Uppercase", name = "uppercase", description="Converts the source string to upper case.",
icon = "uppercase.svg", node_label="Convert {{sourceString}} to upper case| and assign the result to {{returnTo}}|",
return_type=DataType.STRING, return_required = true, return_label="Assign the output to variable",
property_name="uppercase", property_description="Converts the string to upper case", property_type=DataType.STRING,
property_return_type=DataType.STRING) public class UpperCase {
@Execute
public Value<String> convert(
@Idx(index = "1", type=TEXT)
@Pkg(label="Source string")
@NotEmpty
String sourceString){
return new StringValue(sourceString.toUpperCase());
}
}
}