public class Args extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
Args.ValueCreator |
Modifier and Type | Field and Description |
---|---|
static Args.ValueCreator |
ENUM_CREATOR |
static Args.ValueCreator |
FROM_STRING_CONSTRUCTOR
Args.ValueCreator building object using a one arg constructor taking a String object as parameter |
Constructor and Description |
---|
Args() |
Modifier and Type | Method and Description |
---|---|
static Args.ValueCreator |
byStaticMethodInvocation(Class<?> compatibleType,
String methodName)
Creates a
Args.ValueCreator object able to create object assignable from given type,
using a static one arg method which name is the the given one taking a String object as parameter |
static List<String> |
parse(Object target,
String[] args) |
static List<String> |
parse(Object target,
String[] args,
boolean failOnExtraFlags)
Parse a set of arguments and populate the target with the appropriate values.
|
static List<String> |
parseOrExit(Object target,
String[] args)
A convenience method for parsing and automatically producing error messages.
|
static void |
registerValueCreator(Args.ValueCreator vc)
Allows external extension of the valiue creators.
|
static void |
resetValueCreators()
Cleanup of registered ValueCreators (mainly for tests)
|
static void |
usage(Object target)
Generate usage information based on the target annotations.
|
static void |
usage(PrintStream errStream,
Object target)
Generate usage information based on the target annotations.
|
public static final Args.ValueCreator FROM_STRING_CONSTRUCTOR
Args.ValueCreator
building object using a one arg constructor taking a String
object as parameterpublic static final Args.ValueCreator ENUM_CREATOR
public static List<String> parseOrExit(Object target, String[] args)
target
- Either an instance or a classargs
- The arguments you want to parse and populatepublic static List<String> parse(Object target, String[] args, boolean failOnExtraFlags)
target
- Either an instance or a classargs
- The arguments you want to parse and populatefailOnExtraFlags
- Throw an IllegalArgumentException if extra flags are presentpublic static void usage(Object target)
target
- An instance or class.public static void usage(PrintStream errStream, Object target)
errStream
- A PrintStream
to print the usage information to.target
- An instance or class.public static Args.ValueCreator byStaticMethodInvocation(Class<?> compatibleType, String methodName)
Args.ValueCreator
object able to create object assignable from given type,
using a static one arg method which name is the the given one taking a String object as parametercompatibleType
- the base assignable for which this object will try to invoke the given methodmethodName
- the name of the one arg method taking a String as parameter that will be used to built a new valuepublic static void registerValueCreator(Args.ValueCreator vc)
vc
- another value creator to take into account for trying to create valuespublic static void resetValueCreators()
Copyright © 2024. All rights reserved.