org.pentaho.di.core.util
Class KeyValue<T>

java.lang.Object
  extended by org.pentaho.di.core.util.KeyValue<T>
Type Parameters:
T - type of value
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
BooleanPluginProperty, IntegerPluginProperty, StringListPluginProperty, StringPluginProperty

public class KeyValue<T>
extends Object
implements Serializable

Author:
Thomas Hoedl(asc042)
See Also:
Serialized Form

Field Summary
static List<String> DEFAULT_TRUE_VALUES
          The default true values.
static String VALID_KEY_CHARS
          Valid key characters.
 
Constructor Summary
KeyValue(String key)
          Constructor.
KeyValue(String key, T value)
          Constructor.
 
Method Summary
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)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_TRUE_VALUES

public static final List<String> DEFAULT_TRUE_VALUES
The default true values.


VALID_KEY_CHARS

public static final String VALID_KEY_CHARS
Valid key characters.

See Also:
Constant Field Values
Constructor Detail

KeyValue

public KeyValue(String key,
                T value)
         throws IllegalArgumentException
Constructor. Key will be converted to lower case.

Parameters:
key - key to set.
value - value to set, may be null.
Throws:
IllegalArgumentException - if key is invalid.

KeyValue

public KeyValue(String key)
         throws IllegalArgumentException
Constructor. Key will be converted to lower case. Value is null.

Parameters:
key - key to set.
Throws:
IllegalArgumentException - if key is invalid.
Method Detail

assertKey

public static final void assertKey(String lowerKey)
                            throws IllegalArgumentException
Parameters:
lowerKey - key to test.
Throws:
IllegalArgumentException - if key is invalid.

getKey

public String getKey()
Returns:
the key, never null.

getValue

public T getValue()
Returns:
the value

setValue

public void setValue(T value)
Parameters:
value - the value to set

value

public KeyValue<T> value(T newValue)
Parameters:
newValue - value to set.
Returns:
this.

value

public T value()
Returns:
value.

booleanValue

public Boolean booleanValue(String... trueValues)
Parameters:
trueValues - string true values, case is ignored.
Returns:
boolean value, null if value is null.

booleanValue

public Boolean booleanValue(List<String> trueValues)
Parameters:
trueValues - string true values, case is ignored.
Returns:
boolean value, null if value is null.

booleanValue

public Boolean booleanValue(List<String> trueValues,
                            boolean ignoreCase)
Parameters:
trueValues - string true values.
ignoreCase - ignore case?
Returns:
boolean value, null if value is null.

booleanValue

public Boolean booleanValue()
Uses DEFAULT_TRUE_VALUES, ignore case.

Returns:
boolean value or null if value is null.

booleanValue

public Boolean booleanValue(Boolean defaultValue)
Parameters:
defaultValue - the default value
Returns:
boolean value or default value if value is null.

stringValue

public String stringValue()
Returns:
string value or null if value is null.

stringValue

public String stringValue(String defaultValue)
Parameters:
defaultValue - the default value.
Returns:
string value or default value if value is null.

stringValueDefaultIfBlank

public String stringValueDefaultIfBlank(String defaultValue)
Parameters:
defaultValue - the default value.
Returns:
string value or default value if value is blank.

integerValue

public Integer integerValue()
                     throws NumberFormatException
Returns:
integer value or null if value is null.
Throws:
NumberFormatException - if string value of value cannot be converted to Integer

integerValue

public Integer integerValue(Integer defaultValue)
Parameters:
defaultValue - the default value.
Returns:
integer value or default value if value is null or cannot be converted to integer.

longValue

public Long longValue()
               throws NumberFormatException
Returns:
long value or null if value is null.
Throws:
NumberFormatException - if string value of value cannot be converted to Long

longValue

public Long longValue(Long defaultValue)
Parameters:
defaultValue - the default value.
Returns:
long value or default value if value is null or cannot be converted to long.

doubleValue

public Double doubleValue()
                   throws NumberFormatException
Returns:
double value or null if value is null.
Throws:
NumberFormatException - if string value of value cannot be converted to Double

doubleValue

public Double doubleValue(Double defaultValue)
Parameters:
defaultValue - the default value.
Returns:
double value or default value if value is null or cannot be converted to double.

floatValue

public Float floatValue()
                 throws NumberFormatException
Returns:
float value or null if value is null.
Throws:
NumberFormatException - if string value of value cannot be converted to Float

floatValue

public Float floatValue(Float defaultValue)
Parameters:
defaultValue - the default value.
Returns:
float value or default value if value is null or cannot be converted to float.

toString

public String toString()

Overrides:
toString in class Object
See Also:
Object.toString()