T
- type of valuepublic class KeyValue<T> extends Object implements Serializable
Modifier and Type | Field and Description |
---|---|
static List<String> |
DEFAULT_TRUE_VALUES
The default true values.
|
static String |
VALID_KEY_CHARS
Valid key characters.
|
Constructor and Description |
---|
KeyValue(String key)
Constructor.
|
KeyValue(String key,
T value)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static void |
assertKey(String lowerKey) |
Boolean |
booleanValue()
Uses DEFAULT_TRUE_VALUES, ignore case.
|
Boolean |
booleanValue(Boolean defaultValue) |
Boolean |
booleanValue(List<String> trueValues) |
Boolean |
booleanValue(List<String> trueValues,
boolean ignoreCase) |
Boolean |
booleanValue(String... trueValues) |
Double |
doubleValue() |
Double |
doubleValue(Double defaultValue) |
Float |
floatValue() |
Float |
floatValue(Float defaultValue) |
String |
getKey() |
T |
getValue() |
Integer |
integerValue() |
Integer |
integerValue(Integer defaultValue) |
Long |
longValue() |
Long |
longValue(Long defaultValue) |
void |
setValue(T value) |
String |
stringValue() |
String |
stringValue(String defaultValue) |
String |
stringValueDefaultIfBlank(String defaultValue) |
String |
toString() |
T |
value() |
KeyValue<T> |
value(T newValue) |
public static final String VALID_KEY_CHARS
public KeyValue(String key, T value) throws IllegalArgumentException
key
- key to set.value
- value to set, may be null.IllegalArgumentException
- if key is invalid.public KeyValue(String key) throws IllegalArgumentException
key
- key to set.IllegalArgumentException
- if key is invalid.public static final void assertKey(String lowerKey) throws IllegalArgumentException
lowerKey
- key to test.IllegalArgumentException
- if key is invalid.public String getKey()
public T getValue()
public void setValue(T value)
value
- the value to setpublic T value()
public Boolean booleanValue(String... trueValues)
trueValues
- string true values, case is ignored.public Boolean booleanValue(List<String> trueValues)
trueValues
- string true values, case is ignored.public Boolean booleanValue(List<String> trueValues, boolean ignoreCase)
trueValues
- string true values.ignoreCase
- ignore case?public Boolean booleanValue()
public Boolean booleanValue(Boolean defaultValue)
defaultValue
- the default valuepublic String stringValue()
public String stringValue(String defaultValue)
defaultValue
- the default value.public String stringValueDefaultIfBlank(String defaultValue)
defaultValue
- the default value.public Integer integerValue() throws NumberFormatException
NumberFormatException
- if string value of value cannot be converted to Integerpublic Integer integerValue(Integer defaultValue)
defaultValue
- the default value.public Long longValue() throws NumberFormatException
NumberFormatException
- if string value of value cannot be converted to Longpublic Long longValue(Long defaultValue)
defaultValue
- the default value.public Double doubleValue() throws NumberFormatException
NumberFormatException
- if string value of value cannot be converted to Doublepublic Double doubleValue(Double defaultValue)
defaultValue
- the default value.public Float floatValue() throws NumberFormatException
NumberFormatException
- if string value of value cannot be converted to Floatpublic Float floatValue(Float defaultValue)
defaultValue
- the default value.public String toString()
toString
in class Object
Object.toString()
Copyright © 2018 Hitachi Vantara. All rights reserved.