@FunctionalInterface public interface Parser<T>
Consumers, the target consumer
(usually the value setter or adder), and the string consumer that the
Option or Argument needs.
E.g., the following code will create an option '--timestamp' that parses the
argument value as a long (i64) and calls bean.setTimestamp(long)
with that value:
new Option("--timestamp", null, "The timestamp", i64(bean::setTimestamp));
| Modifier and Type | Interface and Description |
|---|---|
static class |
Parser.DirParser
A converter to file instances, with validator & error message.
|
static class |
Parser.DoubleParser
A converter to double values.
|
static class |
Parser.EnumParser<E extends Enum<E>>
A converter to enum constant values.
|
static class |
Parser.FileParser
A converter to file instances, with validator & error message.
|
static class |
Parser.IntegerParser
A converter to integer values.
|
static class |
Parser.LongParser
A converter to long values.
|
static class |
Parser.OutputDirParser
A converter to file instances, with validator & error message.
|
static class |
Parser.OutputFileParser
A converter to file instances, with validator & error message.
|
static class |
Parser.PathParser
A converter to path values.
|
static interface |
Parser.TypedPutter<T> |
| Modifier and Type | Method and Description |
|---|---|
default Consumer<String> |
andApply(Consumer<T> consumer)
Make a string consumer to typed value consumer out of the converter.
|
default Property.Putter |
andPut(Parser.TypedPutter<T> putter)
Make a property putter that calls a typed putter with the parsed value.
|
default Consumer<String> |
andPutAs(Parser.TypedPutter<T> putter,
String key)
Make a consumer that puts a specific value with the typed putter.
|
static Parser<Double> |
dbl()
Make a double parser.
|
static Consumer<String> |
dbl(Consumer<Double> target)
Make a 64-bit integer parsing consumer.
|
static Parser<File> |
dir()
Make a file parser that refers to an existing directory.
|
static Consumer<String> |
dir(Consumer<File> target)
Make a file parsing consumer that refers to an existing directory.
|
static Parser<File> |
file()
Make a file parser that refers to an existing file.
|
static Consumer<String> |
file(Consumer<File> target)
Make a file parsing consumer that refers to an existing file.
|
static Parser<Integer> |
i32()
Make a 32-bit integer parser.
|
static Consumer<String> |
i32(Consumer<Integer> target)
Make a 32-bit integer parsing consumer.
|
static Parser<Long> |
i64()
Make a 64-bit integer parser.
|
static Consumer<String> |
i64(Consumer<Long> target)
Make a 64-bit integer parsing consumer.
|
static <E extends Enum<E>> |
oneOf(Class<E> klass)
Make an enum value parsing consumer.
|
static <E extends Enum<E>> |
oneOf(Class<E> klass,
Consumer<E> target)
Make a file parsing consumer that refers to an existing file.
|
static Parser<File> |
outputDir()
Make a parser that refers either to a non-existing entry or an
existing directory, but not a file or special device.
|
static Consumer<String> |
outputDir(Consumer<File> target)
Make a parsing consumer that refers either to a non-existing entry or an
existing directory, but not a file or special device.
|
static Parser<File> |
outputFile()
Make a file parser that refers either to a non-existing entry or an
existing file, but not a directory or special device.
|
static Consumer<String> |
outputFile(Consumer<File> target)
Make a file parsing consumer that refers either to a non-existing entry or an
existing file, but not a directory or special device.
|
T |
parse(String value)
Parse the value into a typed instance.
|
static Parser<Path> |
path()
Make a parser that parses a path.
|
static Consumer<String> |
path(Consumer<Path> target)
Make a parsing consumer that parses a path.
|
static Consumer<String> |
putAs(Property.Putter putter,
String key)
Convenience method to put a specific value into a putter.
|
T parse(String value)
value - The string value.ArgumentException - If the parsing failed.default Consumer<String> andApply(Consumer<T> consumer)
consumer - The consumer to wrap.default Property.Putter andPut(Parser.TypedPutter<T> putter)
putter - The typed putter.default Consumer<String> andPutAs(Parser.TypedPutter<T> putter, String key)
putter - the typed putter.key - The property key.static Consumer<String> putAs(Property.Putter putter, String key)
putter - The putter.key - The key to put.static Consumer<String> i32(Consumer<Integer> target)
target - The target consumer.static Consumer<String> i64(Consumer<Long> target)
target - The target consumer.static Consumer<String> dbl(Consumer<Double> target)
target - The target consumer.static <E extends Enum<E>> Parser<E> oneOf(Class<E> klass)
E - The enum type.klass - The enum class.static <E extends Enum<E>> Consumer<String> oneOf(Class<E> klass, Consumer<E> target)
E - The enum type.klass - The enum class.target - The target consumer.static Parser<File> file()
static Consumer<String> file(Consumer<File> target)
target - The target consumer.static Parser<File> dir()
static Consumer<String> dir(Consumer<File> target)
target - The target consumer.static Parser<File> outputFile()
static Consumer<String> outputFile(Consumer<File> target)
target - The target consumer.static Parser<File> outputDir()
static Consumer<String> outputDir(Consumer<File> target)
target - The target consumer.Copyright © 2016. All rights reserved.