public class Args extends Object
A key is defined with one or more dashes in the beginning, for example:
'-path' '--path'A key/value pair can be either one single String from the array where there's a '=' delimiter between the key and value, like so:
'--path=/my/path/to/something'...or consist of two (consecutive) strings from the array, like so:
'-path' '/my/path/to/something'Multiple values for an option is supported, however the only means of extracting all values is be using
interpretOptions(String, Function, Function, Validator...)
, all other methods revolve
around single value, i.e. will fail if there are multiple.
Options can have metadata which can be extracted using
interpretOptions(String, Function, Function, Validator...)
. Metadata looks like:
--my-option:Metadata my-valuewhere
Metadata
would be the metadata of my-value
.Modifier and Type | Class and Description |
---|---|
static class |
Args.ArgsParser |
static class |
Args.Option<T> |
Constructor and Description |
---|
Args(org.neo4j.function.Function<String,Args.Option<String>> optionParser,
Map<String,String> source) |
Args(Map<String,String> source) |
Modifier and Type | Method and Description |
---|---|
String[] |
asArgs() |
Map<String,String> |
asMap() |
String |
get(String key) |
String |
get(String key,
String defaultValue) |
String |
get(String key,
String defaultValueIfNotFound,
String defaultValueIfNoValue) |
Boolean |
getBoolean(String key,
Boolean defaultValue) |
Boolean |
getBoolean(String key,
Boolean defaultValueIfNotFound,
Boolean defaultValueIfNoValue) |
long |
getDuration(String key,
long defaultValueInMillis) |
<T extends Enum<T>> |
getEnum(Class<T> enumClass,
String key,
T defaultValue) |
Number |
getNumber(String key,
Number defaultValue) |
boolean |
has(String key) |
boolean |
hasNonNull(String key) |
<T> T |
interpretOption(String key,
org.neo4j.function.Function<String,T> defaultValue,
org.neo4j.function.Function<String,T> converter,
org.neo4j.kernel.impl.util.Validator<T>... validators) |
<T> Collection<T> |
interpretOptions(String key,
org.neo4j.function.Function<String,T> defaultValue,
org.neo4j.function.Function<String,T> converter,
org.neo4j.kernel.impl.util.Validator<T>... validators)
An option can be specified multiple times.
|
<T> Collection<Args.Option<T>> |
interpretOptionsWithMetadata(String key,
org.neo4j.function.Function<String,T> defaultValue,
org.neo4j.function.Function<String,T> converter,
org.neo4j.kernel.impl.util.Validator<T>... validators)
An option can be specified multiple times.
|
<T> T |
interpretOrphan(int index,
org.neo4j.function.Function<String,T> defaultValue,
org.neo4j.function.Function<String,T> converter,
org.neo4j.kernel.impl.util.Validator<T>... validators) |
static String |
jarUsage(Class<?> main,
String... params) |
List<String> |
orphans() |
static Args |
parse(String... args) |
String[] |
source() |
static String[] |
splitLongLine(String description,
int maxLength)
Useful for printing usage where the description itself shouldn't have knowledge about the width
of the window where it's printed.
|
String |
toString() |
static Args.ArgsParser |
withFlags(String... flags) |
public static Args.ArgsParser withFlags(String... flags)
public String[] source()
public boolean has(String key)
public boolean hasNonNull(String key)
public long getDuration(String key, long defaultValueInMillis)
public Boolean getBoolean(String key, Boolean defaultValueIfNotFound, Boolean defaultValueIfNoValue)
public String[] asArgs()
public static String[] splitLongLine(String description, int maxLength)
description
- text to split, if needed.maxLength
- line length to split at, actually closest previous white space.@SafeVarargs public final <T> T interpretOption(String key, org.neo4j.function.Function<String,T> defaultValue, org.neo4j.function.Function<String,T> converter, org.neo4j.kernel.impl.util.Validator<T>... validators)
@SafeVarargs public final <T> Collection<T> interpretOptions(String key, org.neo4j.function.Function<String,T> defaultValue, org.neo4j.function.Function<String,T> converter, org.neo4j.kernel.impl.util.Validator<T>... validators)
Collection
. This is the only means of extracting multiple values
for any given option. All other methods revolve around zero or one value for an option.@SafeVarargs public final <T> Collection<Args.Option<T>> interpretOptionsWithMetadata(String key, org.neo4j.function.Function<String,T> defaultValue, org.neo4j.function.Function<String,T> converter, org.neo4j.kernel.impl.util.Validator<T>... validators)
Collection
. This is the only means of extracting multiple values
for any given option. All other methods revolve around zero or one value for an option.
This is also the only means of extracting metadata about a options. Metadata can be supplied as part
of the option key, like --my-option:Metadata "my value".@SafeVarargs public final <T> T interpretOrphan(int index, org.neo4j.function.Function<String,T> defaultValue, org.neo4j.function.Function<String,T> converter, org.neo4j.kernel.impl.util.Validator<T>... validators)
Copyright © 2002–2015 The Neo4j Graph Database Project. All rights reserved.