Class RMKey

java.lang.Object
com.inductiveautomation.rm.base.RMKey

public class RMKey extends Object
This class provides an optimized convenience for getting named values from arbitrary objects.
  • Constructor Details

    • RMKey

      public RMKey()
  • Method Details

    • isKey

      public static boolean isKey(@Nullable String aString)
      Returns whether given string is a valid key (starts with letter and only contains letters, digits, white space and under bars).
    • getSanitizedKey

      @Nonnull public static String getSanitizedKey(@Nullable String aKey)
      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

      public static Collection<String> getKeys(Object obj)
    • getValue

      public static Object getValue(Object anObj, String aKey)
      Returns a value for given object and key.
    • getValueImpl

      public static Object getValueImpl(Object anObj, String aKey)
      Returns a value for given object and key.
    • setValue

      public static void setValue(Object anObj, String aKey, Object aValue) throws Exception
      Sets a value for given object and key and value.
      Throws:
      Exception
    • setValueSafe

      public static void setValueSafe(Object anObj, String aKey, Object aValue)
      Sets the value but only prints a warning if it fails.
    • setValueSilent

      public static void setValueSilent(Object anObj, String aKey, Object aValue)
      Tries to set value in given object, ignoring failure exceptions.
    • hasKey

      public static boolean hasKey(Object anObj, String aKey)
      Returns whether given object has an accessor for given key.
    • getIntValue

      public static int getIntValue(Object anObj, String aKey)
      Returns an int value for a key.
    • getStringValue

      public static String getStringValue(Object anObj, String aKey)
      Returns a string value for a key.
    • getValue

      public static <T> T getValue(Object anObj, String aKey, Class<T> aClass)
      Returns a value as given class, if appropriate.
    • getAccessor

      public static RMKey.KeyAccessor getAccessor(Object anObj, String aKey)
      Returns the accessor object for a given object (class) and key.
    • getStandard

      public static String getStandard(@Nonnull String aKey)
      Returns the key in a standard format (strip is/get prefix and start with capital letter).