Creation and function annotations
- Updated: 2021/05/10
List of the available creation and function annotations.
Annotation: BotCommand
Makes the type
eligible to be treated as an action
. You can define three types of
actions
commandType
property.
- Command\Action
- Condition
- Iterator
-
@BotCommand(commandType = BotCommand.CommandType.Iterator)
-
@BotCommand(commandType = Condition)
-
@BotCommand(commandType = Varialbe)
-
@BotCommand(commandType = Trigger)
Annotation: CommandPkg
Makes the type eligible for creation of action package.json . This annotation must be used with BotCommand to take effect. Pkg participates in the activity only when this annotation is present.
Example:@CommandPkg(label = "Create", name = "createFile",
description = "Creates a file", node_label = "{{filePath}}",
icon = "file.svg")
Annotation: ConditionTest
Participates in the Condition execution. This annotation can only be used when the BotCommand has commandType set as Condition . Only one method needs to be annotated when BotCommand annotation is present on the type. Failure to do so will result in the compilation error.
Annotation: Execute
Participates in the execution of BotCommand . Exactly one method needs to be annotated when BotCommand annotation is present on the type. Failure to do so will result in the compilation error.
Example:@Execute public void create( @Idx(index = "1", type = FILE) @LocalFile @Pkg(label =
"File", description = "e.g. C:\\MyDoc\\MyFile.doc") @NotEmpty String filePath,
@Idx(index = "2", type = CHECKBOX) @Pkg(label = "Overwrite an existing file")
@NotEmpty Boolean isOverwrite) { createFile(filePath, isOverwrite); }
Annotation: GlobalSessionContext
Can only be applied to member variables and fetches the GlobalSessionContext through a setter.
Example:@com.automationanywhere.commandsdk.annotations.GlobalSessionContext
private GlobalSessionContext globalSessionContext;
public void setSessionMap(Map < String, Object > sessionMap) {
this.sessionMap = sessionMap;
}
public void setGlobalSessionContext(com.automationanywhere.bot.service.GlobalSessionContext globalSessionContext) {
this.globalSessionContext = globalSessionContext;
}
Annotation: HasNext
Participates in the execution of Iterator . This annotation can only be used when the BotCommand has commandType set as Iterator . Requires the Next annotation to be present. One method needs to be annotated when BotCommand annotation is present on the type. Failure to do so will result in the compilation error.
Annotation: Index
Makes the annotated element part of hierarchy utilized for the code and resource generation. Without this annotation no BotCommand related element annotations would be processed.
Annotation: Idx.Option
An option represents the elements that would play in the hierarchy, but lend the values to the parents.
Examples:- RADIO
@Idx(index = "1", type = RADIO, options = { @Idx.Option(index = "1.1", pkg = @Pkg(node_label = "[[Delay.delayType.1.1.node_label]]", label = "[[Delay.delayType.1.1.label]]", value = REGULAR)), @Idx.Option(index = "1.2", pkg = @Pkg(node_label = "[[Delay.delayType.1.2.node_label]]", label = "[[Delay.delayType.1.2.label]]", value = RANDOM)) }) @Pkg(label = "[[Delay.delayType.label]]", default_value = "REGULAR", default_value_type = DataType.STRING) @Inject private String delayType;
- SELECT
@Idx(index = "2", type = SELECT, options = { @Idx.Option(index = "2.1", pkg = @Pkg(label = "[[LaunchWebsite.browser.2.1.label]]", value = "DEFAULT")), @Idx.Option(index = "2.2", pkg = @Pkg(label = "[[LaunchWebsite.browser.2.2.label]]", value = "INTERNET_EXPLORER")), @Idx.Option(index = "2.3", pkg = @Pkg(label = "[[LaunchWebsite.browser.2.3.label]]", value = "FIREFOX")), @Idx.Option(index = "2.4", pkg = @Pkg(label = "[[LaunchWebsite.browser.2.4.label]]", value = "CHROME")) }) @Pkg(label = "[[LaunchWebsite.browser.label]]", default_value = "DEFAULT", default_value_type = DataType.STRING) @NotEmptyStringbrowser)
Annotation: Inject
Makes an element eligible for injection into the annotated type object. The injection is setter-based so a corresponding setter in the type is mandatory. The injected values would form the BotCommand parameter map using the name provided in Idx .
Annotation: Next
Participates in the Iterator execution. This annotation can only be used when the BotCommand has commandType set as Iterator . Requires the HasNext annotation to be present. One method needs to be annotated when BotCommand annotation is present on the type. Failure to do so will result in compilation error.
Annotation: Pkg
Makes an element to participate in the package.json creation. This annotation is ignored when Idx is not present.