@@ -29,8 +29,18 @@ public abstract class CommandRequest {
29
29
* @return the command request
30
30
*/
31
31
public static CommandRequest forAllCommandCompleted (final BaseCommand ... commands ) {
32
+ return forAllCommandCompleted (Arrays .asList (commands ));
33
+ }
34
+
35
+ /**
36
+ * forAllCommandCompleted will wait for all the commands to complete
37
+ *
38
+ * @param commands all the commands
39
+ * @return the command request
40
+ */
41
+ public static CommandRequest forAllCommandCompleted (final List <BaseCommand > commands ) {
32
42
return ImmutableCommandRequest .builder ()
33
- .addAllCommands (Arrays . asList ( commands ) )
43
+ .addAllCommands (commands )
34
44
.commandWaitingType (CommandWaitingType .ALL_COMPLETED )
35
45
.build ();
36
46
}
@@ -42,8 +52,18 @@ public static CommandRequest forAllCommandCompleted(final BaseCommand... command
42
52
* @return the command request
43
53
*/
44
54
public static CommandRequest forAnyCommandCompleted (final BaseCommand ... commands ) {
55
+ return forAnyCommandCompleted (Arrays .asList (commands ));
56
+ }
57
+
58
+ /**
59
+ * forAnyCommandCompleted will wait for any the commands to complete
60
+ *
61
+ * @param commands all the commands
62
+ * @return the command request
63
+ */
64
+ public static CommandRequest forAnyCommandCompleted (final List <BaseCommand > commands ) {
45
65
return ImmutableCommandRequest .builder ()
46
- .addAllCommands (Arrays . asList ( commands ) )
66
+ .addAllCommands (commands )
47
67
.commandWaitingType (CommandWaitingType .ANY_COMPLETED )
48
68
.build ();
49
69
}
@@ -58,8 +78,19 @@ public static CommandRequest forAnyCommandCompleted(final BaseCommand... command
58
78
* @return the command request
59
79
*/
60
80
public static CommandRequest forAnyCommandCombinationCompleted (final List <List <String >> commandCombinationLists , final BaseCommand ... commands ) {
61
- final List <BaseCommand > allSingleCommands = getAllSingleCommands (commands );
62
- final List <String > allNonEmptyCommandsIds = allSingleCommands .stream ()
81
+ return forAnyCommandCombinationCompleted (commandCombinationLists , Arrays .asList (commands ));
82
+ }
83
+ /**
84
+ * This will wait for any combination to complete.
85
+ * Using this requires every command has a commandId when created.
86
+ * Functionally this one can cover both forAllCommandCompleted, forAnyCommandCompleted. So the other two are like "shortcuts" of it.
87
+ *
88
+ * @param commandCombinationLists a list of different combinations, each combination is a list of String as CommandIds
89
+ * @param commands all the commands
90
+ * @return the command request
91
+ */
92
+ public static CommandRequest forAnyCommandCombinationCompleted (final List <List <String >> commandCombinationLists , final List <BaseCommand > commands ) {
93
+ final List <String > allNonEmptyCommandsIds = commands .stream ()
63
94
.filter (command -> command .getCommandId ().isPresent ())
64
95
.map (command -> command .getCommandId ().get ())
65
96
.collect (Collectors .toList ());
@@ -75,13 +106,8 @@ public static CommandRequest forAnyCommandCombinationCompleted(final List<List<S
75
106
});
76
107
return ImmutableCommandRequest .builder ()
77
108
.commandCombinations (combinations )
78
- .addAllCommands (allSingleCommands )
109
+ .addAllCommands (commands )
79
110
.commandWaitingType (CommandWaitingType .ANY_COMBINATION_COMPLETED )
80
111
.build ();
81
112
}
82
-
83
- private static List <BaseCommand > getAllSingleCommands (final BaseCommand ... commands ) {
84
-
85
- return new ArrayList <>(Arrays .asList (commands ));
86
- }
87
113
}
0 commit comments