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
16
17
18
19 public abstract class AbstractCommandExecutor implements ICommandExecutor {
20 @NonNull
21 private final CallingContext callingContext;
22 @NonNull
23 private final CommandLine commandLine;
24
25
26
27
28
29
30
31
32
33 protected AbstractCommandExecutor(
34 @NonNull CallingContext callingContext,
35 @NonNull CommandLine commandLine) {
36 this.callingContext = callingContext;
37 this.commandLine = commandLine;
38 }
39
40
41
42
43
44
45
46 @NonNull
47 protected CallingContext getCallingContext() {
48 return callingContext;
49 }
50
51
52
53
54
55
56
57 @NonNull
58 protected CommandLine getCommandLine() {
59 return commandLine;
60 }
61
62 @Override
63 public abstract void execute() throws CommandExecutionException;
64
65
66
67
68
69
70 @NonNull
71 protected ICommand getCommand() {
72 return ObjectUtils.requireNonNull(getCallingContext().getTargetCommand());
73 }
74 }