Package snap.util
Class Key
java.lang.Object
snap.util.Key
This class provides an optimized convenience for getting named values from arbitrary objects.
-
Nested Class Summary
Modifier 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. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic snap.util.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 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 void
setAllowFields
(boolean aValue) Sets whether Key is allowed to try to resolve values using object fields.static void
Sets a value for given object and key and value.static void
setValueReflect
(Object anObj, String aKey, Object aValue) Sets a value for given object and key and value.static void
setValueReflectSafe
(Object anObj, String aKey, Object aValue) Sets the value but only prints a warning if it fails.static void
setValueSafe
(Object anObj, String aKey, Object aValue) Sets the value but only prints a warning if it fails.
-
Constructor Details
-
Key
public Key()
-
-
Method Details
-
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
-
setValueReflect
Sets a value for given object and key and value.- Throws:
Exception
-
setValueSafe
Sets the value but only prints a warning if it fails. -
setValueReflectSafe
Sets the value but only prints a warning if it fails. -
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). -
setAllowFields
public static void setAllowFields(boolean aValue) Sets whether Key is allowed to try to resolve values using object fields.
-