public class KeyValueParser extends Object
String is a valid key-value
pair if, for key K and for value V, the representation is K=V where the
alphabet for K and V is any symbol except =.
Note that neither K or V can be empty. Any whitespace leading or tailing the
key and value after parsing is removed. Whitespace within the key or value is preserved,
but a key or value cannot consist entirely of whitespace.
| Constructor and Description |
|---|
KeyValueParser()
Setup a default instance of
KeyValueParser. |
KeyValueParser(boolean failFast)
Sets up an instance of
KeyValueParser that throws an IllegalArgumentException
on the first failure during batch operations. |
| Modifier and Type | Method and Description |
|---|---|
Map<String,String> |
parsePairsToMap(List<String> pairList)
|
boolean |
validatePair(String pair)
Given a string, returns true if it is a valid key-value pair.
|
public KeyValueParser()
KeyValueParser.public KeyValueParser(boolean failFast)
KeyValueParser that throws an IllegalArgumentException
on the first failure during batch operations.failFast - Parsing failures throw exceptions if true; otherwise they are silently ignored.public boolean validatePair(String pair)
pair - The string suspected to be of the form "key=value"True if the input is a valid key-value pair. False otherwise.This work is licensed under a Creative Commons Attribution 4.0 International License.