001/* 002 * SPDX-FileCopyrightText: none 003 * SPDX-License-Identifier: CC0-1.0 004 */ 005 006package gov.nist.secauto.metaschema.cli.processor.command; 007 008import gov.nist.secauto.metaschema.cli.processor.CLIProcessor.CallingContext; 009import gov.nist.secauto.metaschema.cli.processor.ExitStatus; 010import gov.nist.secauto.metaschema.core.util.ObjectUtils; 011 012import org.apache.commons.cli.CommandLine; 013 014import edu.umd.cs.findbugs.annotations.NonNull; 015 016public abstract class AbstractCommandExecutor implements ICommandExecutor { 017 @NonNull 018 private final CallingContext callingContext; 019 @NonNull 020 private final CommandLine commandLine; 021 022 public AbstractCommandExecutor( 023 @NonNull CallingContext callingContext, 024 @NonNull CommandLine commandLine) { 025 this.callingContext = callingContext; 026 this.commandLine = commandLine; 027 } 028 029 @NonNull 030 protected CallingContext getCallingContext() { 031 return callingContext; 032 } 033 034 @NonNull 035 protected CommandLine getCommandLine() { 036 return commandLine; 037 } 038 039 @Override 040 public abstract ExitStatus execute(); 041 042 @NonNull 043 protected ICommand getCommand() { 044 return ObjectUtils.requireNonNull(getCallingContext().getTargetCommand()); 045 } 046}