Package com.inductiveautomation.rm.base
Class RMKey
java.lang.Object
com.inductiveautomation.rm.base.RMKey
This class provides an optimized convenience for getting named values from arbitrary objects.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
This is interface is implemented by objects that can get key values themselves.static interface
This is interface is implemented by objects that can get/set key value themselves.static class
KeyAccessor - enclosed class for actually getting/setting values for a given object (class) and key.static interface
static class
NoSetMethodException. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic RMKey.KeyAccessor
getAccessor
(Object anObj, String aKey) Returns the accessor object for a given object (class) and key.static int
getIntValue
(Object anObj, String aKey) Returns an int value for a key.static Collection<String>
static String
getSanitizedKey
(String aKey) Returns the given string with all invalid key characters stripped out.static String
getStandard
(String aKey) Returns the key in a standard format (strip is/get prefix and start with capital letter).static String
getStringValue
(Object anObj, String aKey) Returns a string value for a key.static Object
Returns a value for given object and key.static <T> T
Returns a value as given class, if appropriate.static Object
getValueImpl
(Object anObj, String aKey) Returns a value for given object and key.static boolean
Returns whether given object has an accessor for given key.static boolean
Returns whether given string is a valid key (starts with letter and only contains letters, digits, white space and under bars).static void
Sets a value for given object and key and value.static void
setValueSafe
(Object anObj, String aKey, Object aValue) Sets the value but only prints a warning if it fails.static void
setValueSilent
(Object anObj, String aKey, Object aValue) Tries to set value in given object, ignoring failure exceptions.
-
Constructor Details
-
RMKey
public RMKey()
-
-
Method Details
-
isKey
Returns whether given string is a valid key (starts with letter and only contains letters, digits, white space and under bars). -
getSanitizedKey
Returns the given string with all invalid key characters stripped out. If aKey is blank, null, or contains only invalid characters, resulting string will empty and therefore invalid. Resulting string may also end up being a duplicate of another key -- there's only so much we can do for the user. -
getKeys
-
getValue
Returns a value for given object and key. -
getValueImpl
Returns a value for given object and key. -
setValue
Sets a value for given object and key and value.- Throws:
Exception
-
setValueSafe
Sets the value but only prints a warning if it fails. -
setValueSilent
Tries to set value in given object, ignoring failure exceptions. -
hasKey
Returns whether given object has an accessor for given key. -
getIntValue
Returns an int value for a key. -
getStringValue
Returns a string value for a key. -
getValue
Returns a value as given class, if appropriate. -
getAccessor
Returns the accessor object for a given object (class) and key. -
getStandard
Returns the key in a standard format (strip is/get prefix and start with capital letter).
-