Interface IValueMap

  • All Superinterfaces:
    java.util.Map<java.lang.String,​java.lang.Object>
    All Known Implementing Classes:
    AttributeMap, CopyOnWriteValueMap, ValueMap

    public interface IValueMap
    extends java.util.Map<java.lang.String,​java.lang.Object>
    A Map interface that holds values, parses Strings, and exposes a variety of convenience methods.
    Since:
    1.2.6
    Author:
    Johan Compagner, Doug Donohoe
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.Boolean getAsBoolean​(java.lang.String key)
      Retrieves a Boolean value by key.
      boolean getAsBoolean​(java.lang.String key, boolean defaultValue)
      Retrieves a boolean value by key.
      java.lang.Double getAsDouble​(java.lang.String key)
      Retrieves a Double value by key.
      double getAsDouble​(java.lang.String key, double defaultValue)
      Retrieves a double value by key.
      Duration getAsDuration​(java.lang.String key)
      Retrieves a Duration value by key.
      Duration getAsDuration​(java.lang.String key, Duration defaultValue)
      Retrieves a Duration value by key.
      <T extends java.lang.Enum<T>>
      T
      getAsEnum​(java.lang.String key, java.lang.Class<T> eClass)
      Retrieves an Enum value by key.
      <T extends java.lang.Enum<T>>
      T
      getAsEnum​(java.lang.String key, java.lang.Class<T> eClass, T defaultValue)
      Retrieves an Enum value by key.
      <T extends java.lang.Enum<T>>
      T
      getAsEnum​(java.lang.String key, T defaultValue)
      Retrieves an Enum value by key.
      java.lang.Integer getAsInteger​(java.lang.String key)
      Retrieves an Integer value by key.
      int getAsInteger​(java.lang.String key, int defaultValue)
      Retrieves an integer value by key.
      java.lang.Long getAsLong​(java.lang.String key)
      Retrieves a Long value by key.
      long getAsLong​(java.lang.String key, long defaultValue)
      Retrieves a long value by key.
      Time getAsTime​(java.lang.String key)
      Retrieves a Time value by key.
      Time getAsTime​(java.lang.String key, Time defaultValue)
      Retrieves a Time value by key.
      boolean getBoolean​(java.lang.String key)
      Retrieves a boolean value by key.
      java.lang.CharSequence getCharSequence​(java.lang.String key)
      Retrieves a CharSequence by key.
      double getDouble​(java.lang.String key)
      Retrieves a double value by key.
      double getDouble​(java.lang.String key, double defaultValue)
      Retrieves a double value by key, using a default value if not found.
      Duration getDuration​(java.lang.String key)
      Retrieves a Duration by key.
      int getInt​(java.lang.String key)
      Retrieves an int value by key.
      int getInt​(java.lang.String key, int defaultValue)
      Retrieves an int value by key, using a default value if not found.
      java.lang.String getKey​(java.lang.String key)
      Provided that the hash key is a String and you need to access the value ignoring the key's case (upper- or lowercase letters), then you may use this method to get the correct writing.
      long getLong​(java.lang.String key)
      Retrieves a long value by key.
      long getLong​(java.lang.String key, long defaultValue)
      Retrieves a long value by key, using a default value if not found.
      java.lang.String getString​(java.lang.String key)
      Retrieves a String by key.
      java.lang.String getString​(java.lang.String key, java.lang.String defaultValue)
      Retrieves a String by key, using a default value if not found.
      java.lang.String[] getStringArray​(java.lang.String key)
      Retrieves a String array by key.
      StringValue getStringValue​(java.lang.String key)
      Retrieves a StringValue object by key.
      Time getTime​(java.lang.String key)
      Retrieves a Time object by key.
      boolean isImmutable()
      Returns whether or not this IValueMap is immutable.
      IValueMap makeImmutable()
      Makes this IValueMap immutable by changing the underlying map representation to a Collections.unmodifiableMap.
      • Methods inherited from interface java.util.Map

        clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
    • Method Detail

      • getDouble

        double getDouble​(java.lang.String key,
                         double defaultValue)
                  throws StringValueConversionException
        Retrieves a double value by key, using a default value if not found.
        Parameters:
        key - the key
        defaultValue - value to use if no value is in this IValueMap
        Returns:
        the value
        Throws:
        StringValueConversionException
      • getInt

        int getInt​(java.lang.String key,
                   int defaultValue)
            throws StringValueConversionException
        Retrieves an int value by key, using a default value if not found.
        Parameters:
        key - the key
        defaultValue - value to use if no value is in this IValueMap
        Returns:
        the value
        Throws:
        StringValueConversionException
      • getLong

        long getLong​(java.lang.String key,
                     long defaultValue)
              throws StringValueConversionException
        Retrieves a long value by key, using a default value if not found.
        Parameters:
        key - the key
        defaultValue - value to use if no value in this IValueMap
        Returns:
        the value
        Throws:
        StringValueConversionException
      • getString

        java.lang.String getString​(java.lang.String key,
                                   java.lang.String defaultValue)
        Retrieves a String by key, using a default value if not found.
        Parameters:
        key - the key
        defaultValue - default value to return if value is null
        Returns:
        the String
      • getString

        java.lang.String getString​(java.lang.String key)
        Retrieves a String by key.
        Parameters:
        key - the key
        Returns:
        the String
      • getCharSequence

        java.lang.CharSequence getCharSequence​(java.lang.String key)
        Retrieves a CharSequence by key.
        Parameters:
        key - the key
        Returns:
        the CharSequence
      • getStringArray

        java.lang.String[] getStringArray​(java.lang.String key)
        Retrieves a String array by key. If the value was a String[] it will be returned directly. If it was a String it will be converted to a String array of length one. If it was an array of another type, a String array will be made and each element will be converted to a String.
        Parameters:
        key - the key
        Returns:
        the String array of that key
      • getStringValue

        StringValue getStringValue​(java.lang.String key)
        Retrieves a StringValue object by key.
        Parameters:
        key - the key
        Returns:
        the StringValue object
      • isImmutable

        boolean isImmutable()
        Returns whether or not this IValueMap is immutable.
        Returns:
        whether or not this IValueMap is immutable
      • makeImmutable

        IValueMap makeImmutable()
        Makes this IValueMap immutable by changing the underlying map representation to a Collections.unmodifiableMap. After calling this method, any attempt to modify this IValueMap will result in a RuntimeException being thrown by the Collections framework.
        Returns:
        this IValueMap
      • getKey

        java.lang.String getKey​(java.lang.String key)
        Provided that the hash key is a String and you need to access the value ignoring the key's case (upper- or lowercase letters), then you may use this method to get the correct writing.
        Parameters:
        key - the key
        Returns:
        the key with the correct writing
      • getAsBoolean

        java.lang.Boolean getAsBoolean​(java.lang.String key)
        Retrieves a Boolean value by key.
        Parameters:
        key - the key
        Returns:
        the value or null if value is not a valid boolean or no value is in this IValueMap
      • getAsBoolean

        boolean getAsBoolean​(java.lang.String key,
                             boolean defaultValue)
        Retrieves a boolean value by key.
        Parameters:
        key - the key
        defaultValue - the default to return
        Returns:
        the value or defaultValue if value is not a valid boolean or no value is in this IValueMap
      • getAsInteger

        java.lang.Integer getAsInteger​(java.lang.String key)
        Retrieves an Integer value by key.
        Parameters:
        key - the key
        Returns:
        the value or null if value is not a valid integer or no value is in this IValueMap
      • getAsInteger

        int getAsInteger​(java.lang.String key,
                         int defaultValue)
        Retrieves an integer value by key.
        Parameters:
        key - the key
        defaultValue - the default to return
        Returns:
        the value or defaultValue if value is not a valid integer or no value is in this IValueMap
      • getAsLong

        java.lang.Long getAsLong​(java.lang.String key)
        Retrieves a Long value by key.
        Parameters:
        key - the key
        Returns:
        the value or null if value is not a valid long or no value is in this IValueMap
      • getAsLong

        long getAsLong​(java.lang.String key,
                       long defaultValue)
        Retrieves a long value by key.
        Parameters:
        key - the key
        defaultValue - the default to return
        Returns:
        the value or defaultValue if value is not a valid long or no value is in this IValueMap
      • getAsDouble

        java.lang.Double getAsDouble​(java.lang.String key)
        Retrieves a Double value by key.
        Parameters:
        key - the key
        Returns:
        the value or null if value is not a valid double or no value is in this IValueMap
      • getAsDouble

        double getAsDouble​(java.lang.String key,
                           double defaultValue)
        Retrieves a double value by key.
        Parameters:
        key - the key
        defaultValue - the default to return
        Returns:
        the value or defaultValue if value is not a valid double or no value is in this IValueMap
      • getAsDuration

        Duration getAsDuration​(java.lang.String key)
        Retrieves a Duration value by key.
        Parameters:
        key - the key
        Returns:
        the value or null if value is not a valid Duration or no value is in this IValueMap
      • getAsDuration

        Duration getAsDuration​(java.lang.String key,
                               Duration defaultValue)
        Retrieves a Duration value by key.
        Parameters:
        key - the key
        defaultValue - the default to return
        Returns:
        the value or defaultValue if value is not a valid Duration or no value is in this IValueMap
      • getAsTime

        Time getAsTime​(java.lang.String key)
        Retrieves a Time value by key.
        Parameters:
        key - the key
        Returns:
        the value or null if value is not a valid Time or no value is in this IValueMap
      • getAsTime

        Time getAsTime​(java.lang.String key,
                       Time defaultValue)
        Retrieves a Time value by key.
        Parameters:
        key - the key
        defaultValue - the default to return
        Returns:
        the value or defaultValue if value is not a valid Time or no value is in this IValueMap
      • getAsEnum

        <T extends java.lang.Enum<T>> T getAsEnum​(java.lang.String key,
                                                  java.lang.Class<T> eClass)
        Retrieves an Enum value by key.
        Type Parameters:
        T - type of enum
        Parameters:
        key - the key
        eClass - the enumeration class
        Returns:
        the value or null if value is not a valid value of the Enumeration or no value is in this IValueMap
      • getAsEnum

        <T extends java.lang.Enum<T>> T getAsEnum​(java.lang.String key,
                                                  T defaultValue)
        Retrieves an Enum value by key.
        Type Parameters:
        T - type of enum
        Parameters:
        key - the key
        defaultValue - the default value from the Enumeration (cannot be null)
        Returns:
        the value or defaultValue if value is not a valid value of the Enumeration or no value is in this IValueMap
      • getAsEnum

        <T extends java.lang.Enum<T>> T getAsEnum​(java.lang.String key,
                                                  java.lang.Class<T> eClass,
                                                  T defaultValue)
        Retrieves an Enum value by key.
        Type Parameters:
        T - type of enum
        Parameters:
        key - the key
        eClass - the enumeration class
        defaultValue - the default value from the Enumeration (may be null)
        Returns:
        the value or defaultValue if value is not a valid value of the Enumeration or no value is in this IValueMap