Use a Collection instead of a List to hold the command and arguments

This commit is contained in:
Erik C. Thauvin 2024-06-21 00:08:04 -07:00
parent e601ffab91
commit 35287d7d6d
Signed by: erik
GPG key ID: 776702A6A2DA330E
2 changed files with 16 additions and 12 deletions

View file

@ -37,7 +37,7 @@ import java.util.logging.Logger;
*/
public class ExecOperation extends AbstractOperation<ExecOperation> {
private static final Logger LOGGER = Logger.getLogger(ExecOperation.class.getName());
private final List<String> args_ = new ArrayList<>();
private final Collection<String> args_ = new ArrayList<>();
private boolean failOnExit_ = true;
private BaseProject project_;
private int timeout_ = 30;
@ -61,6 +61,16 @@ public class ExecOperation extends AbstractOperation<ExecOperation> {
return this;
}
/**
* Returns the command and arguments to be executed.
*
* @return the command and arguments
*/
public Collection<String> command() {
return args_;
}
/**
* Configures the command and arguments to be executed.
*
@ -92,7 +102,7 @@ public class ExecOperation extends AbstractOperation<ExecOperation> {
if (workDir.isDirectory()) {
var pb = new ProcessBuilder();
pb.inheritIO();
pb.command(args_);
pb.command(args_.stream().toList());
pb.directory(workDir);
if (LOGGER.isLoggable(Level.INFO)) {