Package berlin.yuna.clu.logic
Class ArgumentReader
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.concurrent.ConcurrentHashMap<String,List<String>>
-
- berlin.yuna.clu.logic.ArgumentReader
-
- All Implemented Interfaces:
Serializable,ConcurrentMap<String,List<String>>,Map<String,List<String>>
public class ArgumentReader extends ConcurrentHashMap<String,List<String>>
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.concurrent.ConcurrentHashMap
ConcurrentHashMap.KeySetView<K extends Object,V extends Object>
-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Field Summary
Fields Modifier and Type Field Description protected List<String>commandList
-
Constructor Summary
Constructors Modifier Constructor Description protectedArgumentReader(boolean parseEnv, String... args)Parses a string arguments into key value
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ArgumentReaderaddCommands(String[] cmdList)protected ArgumentReaderaddKV(String key, String value)booleanequals(Object o)List<String>get(String key)getList<String>get(String separator, String key)getbooleangetBoolean(int index, String... keys)getBooleanbooleangetBoolean(String... keys)getBooleanbooleangetBoolean(String separator, int index, String... keys)getBooleanList<Boolean>getBooleans(String... keys)getBooleanList<Boolean>getBooleans(String separator, String[] keys)getBooleanStringgetCommand()get commandStringgetCommand(int index)get commandList<String>getCommands()get commandsOptional<Double>getDouble(int index, String... keys)getDoubleOptional<Double>getDouble(String... keys)getDoubleOptional<Double>getDouble(String separator, int index, String... keys)getDoubleList<Double>getDoubles(char separator, String... keys)getDoublesList<Double>getDoubles(String... keys)getDoublesList<Double>getDoubles(String separator, String[] keys)getDoublesOptional<Long>getLong(int index, String... keys)getLongOptional<Long>getLong(String... keys)Optional<Long>getLong(String separator, int index, String... keys)getLongList<Long>getLongs(char separator, String... keys)getLongsList<Long>getLongs(String... keys)getLongsList<Long>getLongs(String separator, String[] keys)getLongsOptional<String>getString(int index, String... keys)getStringOptional<String>getString(String... keys)getStringOptional<String>getString(String separator, int index, String... keys)getStringList<String>getStrings(char separator, String... keys)getStringsList<String>getStrings(String... keys)getStringsList<String>getStrings(String separator, String[] keys)getStringsprotected StringgetStripedValue(String value)protected StringgetValue(String separator, int index, String... keys)getValueprotected List<String>getValues(String separator, String[] keys)booleanhasCommand(String command)has commandinthashCode()booleanisPresent(String... keys)isPresentstatic ArgumentReaderparseArgs(boolean parseEnv, String... args)Parses a string arguments into key values
example: [mvn clean install --Dencoding="UTF-8", --javaVersion 8 -v=true --args=1,2,3]
example (commands): [mvn, clean, install]
example (kv): [Dencoding=UTF-8, javaVersion=8, v=true, args=1,2,3]
See:
getString(String, int, String...)
getLong(String, int, String...)
getDouble(String, int, String...)
getValue(String, int, String...)
get(String, String)
getCommands()
hasCommand(String)static ArgumentReaderparseArgs(String... args)Parses a string arguments into key values
example: [mvn clean install --Dencoding="UTF-8", --javaVersion 8 -v=true --args=1,2,3]
example (commands): [mvn, clean, install]
example (kv): [Dencoding=UTF-8, javaVersion=8, v=true, args=1,2,3]
See:
getString(String, int, String...)
getLong(String, int, String...)
getDouble(String, int, String...)
getValue(String, int, String...)
get(String, String)
getCommands()
hasCommand(String)protected ArgumentReaderparseCommandLine(String input)protected StringparseCommands(String input)ArgumentReaderparseEnvironment()protected String[]parseToKeyValue(String argument)protected List<String>removeDuplicates(List<String> result)protected Function<String,Boolean>toBoolean()protected Function<String,Double>toDouble()protected Function<String,Long>toLong()-
Methods inherited from class java.util.concurrent.ConcurrentHashMap
clear, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, forEach, forEach, forEach, forEachEntry, forEachEntry, forEachKey, forEachKey, forEachValue, forEachValue, get, getOrDefault, isEmpty, keys, keySet, keySet, mappingCount, merge, newKeySet, newKeySet, put, putAll, putIfAbsent, reduce, reduceEntries, reduceEntries, reduceEntriesToDouble, reduceEntriesToInt, reduceEntriesToLong, reduceKeys, reduceKeys, reduceKeysToDouble, reduceKeysToInt, reduceKeysToLong, reduceToDouble, reduceToInt, reduceToLong, reduceValues, reduceValues, reduceValuesToDouble, reduceValuesToInt, reduceValuesToLong, remove, remove, replace, replace, replaceAll, search, searchEntries, searchKeys, searchValues, size, toString, values
-
Methods inherited from class java.util.AbstractMap
clone
-
-
-
-
Constructor Detail
-
ArgumentReader
protected ArgumentReader(boolean parseEnv, String... args)Parses a string arguments into key value- Parameters:
args- strings with arguments
-
-
Method Detail
-
parseArgs
public static ArgumentReader parseArgs(String... args)
Parses a string arguments into key values
example: [mvn clean install --Dencoding="UTF-8", --javaVersion 8 -v=true --args=1,2,3]
example (commands): [mvn, clean, install]
example (kv): [Dencoding=UTF-8, javaVersion=8, v=true, args=1,2,3]
See:
getString(String, int, String...)
getLong(String, int, String...)
getDouble(String, int, String...)
getValue(String, int, String...)
get(String, String)
getCommands()
hasCommand(String)- Parameters:
args- strings with arguments
-
parseArgs
public static ArgumentReader parseArgs(boolean parseEnv, String... args)
Parses a string arguments into key values
example: [mvn clean install --Dencoding="UTF-8", --javaVersion 8 -v=true --args=1,2,3]
example (commands): [mvn, clean, install]
example (kv): [Dencoding=UTF-8, javaVersion=8, v=true, args=1,2,3]
See:
getString(String, int, String...)
getLong(String, int, String...)
getDouble(String, int, String...)
getValue(String, int, String...)
get(String, String)
getCommands()
hasCommand(String)- Parameters:
args- strings with argumentsparseEnv- if true, will also parse environment variables
-
getCommand
public String getCommand()
get command- Returns:
- command
-
getCommand
public String getCommand(int index)
get command- Parameters:
index- number of command- Returns:
- command or null if no command were found
-
hasCommand
public boolean hasCommand(String command)
has command- Returns:
- true if command exists
-
isPresent
public boolean isPresent(String... keys)
isPresent- Parameters:
keys- search for- Returns:
- true if one key is present
-
getString
public Optional<String> getString(String... keys)
getString- Parameters:
keys- search for- Returns:
- returns
Optionalvalue orOptional.empty()if no value is present
-
getString
public Optional<String> getString(int index, String... keys)
getString- Parameters:
keys- search forindex- number of value- Returns:
- returns
Optionalvalue orOptional.empty()if no value is present
-
getString
public Optional<String> getString(String separator, int index, String... keys)
getString- Parameters:
keys- search forindex- number of valueseparator- handles values as list if present- Returns:
- returns
Optionalvalue orOptional.empty()if no value is present
-
getStrings
public List<String> getStrings(String... keys)
getStrings- Parameters:
keys- search for- Returns:
- returns values or empty list if no value is present
-
getStrings
public List<String> getStrings(char separator, String... keys)
getStrings- Parameters:
keys- search forseparator- handles values as list if present- Returns:
- returns values or empty list if no value is present
-
getStrings
public List<String> getStrings(String separator, String[] keys)
getStrings- Parameters:
keys- search forseparator- handles values as list if present- Returns:
- returns values or empty list if no value is present
-
getBoolean
public boolean getBoolean(String... keys)
getBoolean- Parameters:
keys- search for- Returns:
- true if [value == 1], [value == true], [key != && value == null]
-
getBoolean
public boolean getBoolean(int index, String... keys)getBoolean- Parameters:
keys- search forindex- number of value- Returns:
- true if [value == 1], [value == true], [key != && value == null]
-
getBoolean
public boolean getBoolean(String separator, int index, String... keys)
getBoolean- Parameters:
keys- search forindex- number of valueseparator- handles values as list if present- Returns:
- true if [value == 1], [value == true], [key != && value == null]
-
getBooleans
public List<Boolean> getBooleans(String... keys)
getBoolean- Parameters:
keys- search for- Returns:
- boolean list if [value == 1], [value == true]
-
getBooleans
public List<Boolean> getBooleans(String separator, String[] keys)
getBoolean- Parameters:
keys- search forseparator- handles values as list if present- Returns:
- boolean list if [value == 1], [value == true]
-
get
public List<String> get(String key)
get- Parameters:
key- search for- Returns:
- list of values or empty list if not found
-
get
public List<String> get(String separator, String key)
get- Parameters:
key- search forseparator- handles values as list if present- Returns:
- list of values or empty list if not found
-
parseEnvironment
public ArgumentReader parseEnvironment()
-
parseCommandLine
protected ArgumentReader parseCommandLine(String input)
-
addKV
protected ArgumentReader addKV(String key, String value)
-
addCommands
protected ArgumentReader addCommands(String[] cmdList)
-
getValue
protected String getValue(String separator, int index, String... keys)
getValue- Parameters:
keys- search forindex- number of valueseparator- handles values as list if present- Returns:
- value or null if no value was found
-
equals
public boolean equals(Object o)
-
-