将操作作为属性公开
如果某个操作不接受任何参数,则该操作可以作为属性公开。这可以通过在 CommandPkg 上设置以下属性来完成。
Action 属性值
- property_name
- 属性的名称,在操作级别是唯一的,在自动完成框中将显示此名称。
- property_description
- 属性的描述。
- property_type
- 操作属性的数据类型,只有该类型匹配时,该属性才会显示在自动完成框中。
- property_return_type
- 属性返回的数据类型。如果此类型与使用它的字段类型不匹配,将出现验证错误。
@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());
}
}