1
2
3
4
5
6 package gov.nist.secauto.metaschema.cli.processor.command;
7
8 import gov.nist.secauto.metaschema.cli.processor.CLIProcessor.CallingContext;
9 import gov.nist.secauto.metaschema.core.util.ObjectUtils;
10
11 import org.apache.commons.cli.CommandLine;
12
13 import edu.umd.cs.findbugs.annotations.NonNull;
14
15 public abstract class AbstractCommandExecutor implements ICommandExecutor {
16 @NonNull
17 private final CallingContext callingContext;
18 @NonNull
19 private final CommandLine commandLine;
20
21 public AbstractCommandExecutor(
22 @NonNull CallingContext callingContext,
23 @NonNull CommandLine commandLine) {
24 this.callingContext = callingContext;
25 this.commandLine = commandLine;
26 }
27
28 @NonNull
29 protected CallingContext getCallingContext() {
30 return callingContext;
31 }
32
33 @NonNull
34 protected CommandLine getCommandLine() {
35 return commandLine;
36 }
37
38 @Override
39 public abstract void execute() throws CommandExecutionException;
40
41 @NonNull
42 protected ICommand getCommand() {
43 return ObjectUtils.requireNonNull(getCallingContext().getTargetCommand());
44 }
45 }