@ThreadSafe public final class CommandUtils extends Object
Command
.Modifier and Type | Method and Description |
---|---|
static void |
checkNumOfArgsEquals(Command cmd,
org.apache.commons.cli.CommandLine cl,
int n)
Checks the number of non-option arguments equals n for command.
|
static void |
checkNumOfArgsNoLessThan(Command cmd,
org.apache.commons.cli.CommandLine cl,
int n)
Checks the number of non-option arguments is no less than n for command.
|
static void |
checkNumOfArgsNoMoreThan(Command cmd,
org.apache.commons.cli.CommandLine cl,
int n)
Checks the number of non-option arguments is no more than n for command.
|
static Map<String,Command> |
loadCommands(String pkgName,
Class[] classArgs,
Object[] objectArgs)
Get instances of all subclasses of
Command in a sub-package called "command" the given
package. |
static Set<String> |
readNodeList(String confDir,
String fileName)
Reads a list of nodes from given file name ignoring comments and empty lines.
|
public static Map<String,Command> loadCommands(String pkgName, Class[] classArgs, Object[] objectArgs)
Command
in a sub-package called "command" the given
package.pkgName
- package prefix to look inclassArgs
- type of args to instantiate the classobjectArgs
- args to instantiate the classpublic static void checkNumOfArgsEquals(Command cmd, org.apache.commons.cli.CommandLine cl, int n) throws InvalidArgumentException
cmd
- command instancecl
- parsed commandline argumentsn
- an integerInvalidArgumentException
- if the number does not equal npublic static void checkNumOfArgsNoLessThan(Command cmd, org.apache.commons.cli.CommandLine cl, int n) throws InvalidArgumentException
cmd
- command instancecl
- parsed commandline argumentsn
- an integerInvalidArgumentException
- if the number is smaller than npublic static void checkNumOfArgsNoMoreThan(Command cmd, org.apache.commons.cli.CommandLine cl, int n) throws InvalidArgumentException
cmd
- command instancecl
- parsed commandline argumentsn
- an integerInvalidArgumentException
- if the number is greater than n@Nullable public static Set<String> readNodeList(String confDir, String fileName)
confDir
- directory that holds the configurationfileName
- name of a file that contains the list of the nodesCopyright © 2023. All Rights Reserved.