Class MapUtil


  • public final class MapUtil
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      MapUtil()  
      MapUtil​(java.util.Map<java.lang.String,​java.lang.Object> map)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean getBoolean​(java.lang.String name)
      Return the boolean associated to the key put in parameter ("name")
      boolean getBoolean​(java.lang.String name, boolean defaultValue)
      Return the boolean associated to the key put in parameter ("name").
      byte getByte​(java.lang.String name)
      Returns the byte associated to the key put in parameter ("name").
      byte getByte​(java.lang.String name, byte defaultValue)
      Returns the int associated to the key put in parameter ("name").
      double getDouble​(java.lang.String name)
      Returns the double associated to the key put in parameter ("name").
      double getDouble​(java.lang.String name, float defaultValue)
      Returns the double associated to the key put in parameter ("name").
      <T extends java.lang.Enum<T>>
      T
      getEnum​(java.lang.String name, java.lang.Class<T> enumClass)
      Returns an enumeration of <T> from the set
      <T extends java.lang.Enum<T>>
      T
      getEnum​(java.lang.String name, java.lang.Class<T> enumClass, T defaultValue)
      Returns an enumeration of <T> from the set.
      <T extends java.lang.Enum<T>>
      java.util.List<T>
      getEnumList​(java.lang.String key, java.lang.Class<T> clazz)  
      <T extends java.lang.Enum<T>>
      java.util.Set<T>
      getEnumSet​(java.lang.String key, java.lang.Class<T> clazz)  
      float getFloat​(java.lang.String name)
      Returns the float associated to the key put in parameter ("name").
      float getFloat​(java.lang.String name, float defaultValue)
      Returns the float associated to the key put in parameter ("name").
      float[] getFloatArray​(java.lang.String name, java.lang.String delimiter)  
      int getInt​(java.lang.String name)
      Returns the int associated to the key put in parameter ("name").
      int[] getIntArray​(java.lang.String name, java.lang.String delimiter)
      Returns the int[] associated to the key put in parameter ("name").
      int getInteger​(java.lang.String name, int defaultValue)
      Returns the int associated to the key put in parameter ("name").
      java.util.Map<java.lang.String,​java.lang.Object> getInternalMap()
      Returns the set of values
      <T> java.util.List<T> getList​(java.lang.String key, java.lang.Class<T> clazz)  
      <T> java.util.List<T> getList​(java.lang.String key, java.lang.Class<T> clazz, java.util.List<T> defaultValue)  
      long getLong​(java.lang.String name)
      Returns the long associated to the key put in parameter ("name").
      long getLong​(java.lang.String name, int defaultValue)
      Returns the long associated to the key put in parameter ("name").
      <K,​V>
      java.util.Map<K,​V>
      getMap​(java.lang.String key, java.lang.Class<K> keyClass, java.lang.Class<V> valueClass)  
      <K,​V>
      java.util.Map<K,​java.util.List<V>>
      getMapOfList​(java.lang.String key, java.lang.Class<K> keyClass, java.lang.Class<V> valueClass)  
      <A> A getObject​(java.lang.String name, java.lang.Class<A> type)  
      <T> java.util.Set<T> getSet​(java.lang.String key, java.lang.Class<T> clazz)  
      <T> java.util.Set<T> getSet​(java.lang.String key, java.lang.Class<T> clazz, java.util.Set<T> defaultValue)  
      short getShort​(java.lang.String name)
      Returns the short associated to the key put in parameter ("name").
      short getShort​(java.lang.String name, short defaultValue)
      Returns the short associated to the key put in parameter ("name").
      java.lang.String getString​(java.lang.String name)
      Returns the String associated to the key put in parameter ("name").
      java.lang.String getString​(java.lang.String name, java.lang.String defaultValue)
      Returns the String associated to the key put in parameter ("name").
      void merge​(MapUtil newSet)
      Add a set of couple values in the current set
      MapUtil put​(java.lang.String name, java.lang.Object value)
      Puts key-value pair inside the internal map, replacing previously existing key
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MapUtil

        public MapUtil()
      • MapUtil

        public MapUtil​(java.util.Map<java.lang.String,​java.lang.Object> map)
    • Method Detail

      • getInternalMap

        public final java.util.Map<java.lang.String,​java.lang.Object> getInternalMap()
        Returns the set of values
        Returns:
        HashMap
      • merge

        public void merge​(MapUtil newSet)
        Add a set of couple values in the current set
        Parameters:
        newSet - : MapSet pointing out the list of couples to add in the current set
      • put

        public MapUtil put​(java.lang.String name,
                           java.lang.Object value)
        Puts key-value pair inside the internal map, replacing previously existing key
        Parameters:
        name -
        value -
        Returns:
        the same instance of current MapSet so it can be chained like:
        mapSet.put("key", "value").put("another key", "another value");
      • getBoolean

        public boolean getBoolean​(java.lang.String name)
        Return the boolean associated to the key put in parameter ("name")
        Parameters:
        name - : String designating the key in the set
        Returns:
        boolean : value associated to the key
      • getBoolean

        public boolean getBoolean​(java.lang.String name,
                                  boolean defaultValue)
        Return the boolean associated to the key put in parameter ("name"). If the value associated to the key is null, this method returns the value of the parameter defaultValue.
        Parameters:
        name - : String designating the key in the set
        defaultValue - : boolean designating the default value if value associated with the key is null
        Returns:
        boolean : value of the key
      • getByte

        public byte getByte​(java.lang.String name,
                            byte defaultValue)
        Returns the int associated to the key put in parameter ("name"). If the value associated to the key is null, this method returns the value of the parameter defaultValue.
        Parameters:
        name - : String designating the key in the set
        defaultValue - : byte designating the default value if value associated with the key is null
        Returns:
        byte : value associated to the key
      • getByte

        public byte getByte​(java.lang.String name)
        Returns the byte associated to the key put in parameter ("name").
        Parameters:
        name - : String designating the key in the set
        Returns:
        byte : value associated to the key
      • getShort

        public short getShort​(java.lang.String name,
                              short defaultValue)
        Returns the short associated to the key put in parameter ("name"). If the value associated to the key is null, this method returns the value of the parameter defaultValue.
        Parameters:
        name - : String designating the key in the set
        defaultValue - : short designating the default value if value associated with the key is null
        Returns:
        short : value associated to the key
      • getShort

        public short getShort​(java.lang.String name)
        Returns the short associated to the key put in parameter ("name").
        Parameters:
        name - : String designating the key in the set
        Returns:
        short : value associated to the key
      • getInt

        public int getInt​(java.lang.String name)
        Returns the int associated to the key put in parameter ("name").
        Parameters:
        name - : String designating the key in the set
        Returns:
        int : value associated to the key
      • getInteger

        public int getInteger​(java.lang.String name,
                              int defaultValue)
        Returns the int associated to the key put in parameter ("name"). If the value associated to the key is null, this method returns the value of the parameter defaultValue.
        Parameters:
        name - : String designating the key in the set
        defaultValue - : int designating the default value if value associated with the key is null
        Returns:
        int : value associated to the key
      • getIntArray

        public int[] getIntArray​(java.lang.String name,
                                 java.lang.String delimiter)
        Returns the int[] associated to the key put in parameter ("name"). If the value associated to the key is null, this method returns the value of the parameter defaultValue.
        Parameters:
        name - : String designating the key in the set
        delimiter -
        Returns:
        int[] : value associated to the key
      • getFloatArray

        public float[] getFloatArray​(java.lang.String name,
                                     java.lang.String delimiter)
      • getLong

        public long getLong​(java.lang.String name)
        Returns the long associated to the key put in parameter ("name").
        Parameters:
        name - : String designating the key in the set
        Returns:
        long : value associated to the key
      • getLong

        public long getLong​(java.lang.String name,
                            int defaultValue)
        Returns the long associated to the key put in parameter ("name"). If the value associated to the key is null, this method returns the value of the parameter defaultValue.
        Parameters:
        name - : String designating the key in the set
        defaultValue - : long designating the default value if value associated with the key is null
        Returns:
        long : value associated to the key
      • getFloat

        public float getFloat​(java.lang.String name)
        Returns the float associated to the key put in parameter ("name").
        Parameters:
        name - : String designating the key in the set
        Returns:
        float : value associated to the key
      • getFloat

        public float getFloat​(java.lang.String name,
                              float defaultValue)
        Returns the float associated to the key put in parameter ("name"). If the value associated to the key is null, this method returns the value of the parameter defaultValue.
        Parameters:
        name - : String designating the key in the set
        defaultValue - : float designating the default value if value associated with the key is null
        Returns:
        float : value associated to the key
      • getDouble

        public double getDouble​(java.lang.String name)
        Returns the double associated to the key put in parameter ("name").
        Parameters:
        name - : String designating the key in the set
        Returns:
        double : value associated to the key
      • getDouble

        public double getDouble​(java.lang.String name,
                                float defaultValue)
        Returns the double associated to the key put in parameter ("name"). If the value associated to the key is null, this method returns the value of the parameter defaultValue.
        Parameters:
        name - : String designating the key in the set
        defaultValue - : float designating the default value if value associated with the key is null
        Returns:
        double : value associated to the key
      • getString

        public java.lang.String getString​(java.lang.String name)
        Returns the String associated to the key put in parameter ("name").
        Parameters:
        name - : String designating the key in the set
        Returns:
        String : value associated to the key
      • getString

        public java.lang.String getString​(java.lang.String name,
                                          java.lang.String defaultValue)
        Returns the String associated to the key put in parameter ("name"). If the value associated to the key is null, this method returns the value of the parameter defaultValue.
        Parameters:
        name - : String designating the key in the set
        defaultValue - : String designating the default value if value associated with the key is null
        Returns:
        String : value associated to the key
      • getEnum

        public <T extends java.lang.Enum<T>> T getEnum​(java.lang.String name,
                                                       java.lang.Class<T> enumClass)
        Returns an enumeration of <T> from the set
        Type Parameters:
        T - : Class of the enumeration returned
        Parameters:
        name - : String designating the key in the set
        enumClass - : Class designating the class of the value associated with the key in the set
        Returns:
        Enum
      • getEnum

        public <T extends java.lang.Enum<T>> T getEnum​(java.lang.String name,
                                                       java.lang.Class<T> enumClass,
                                                       T defaultValue)
        Returns an enumeration of <T> from the set. If the enumeration is empty, the method returns the value of the parameter "defaultValue".
        Type Parameters:
        T - : Class of the enumeration returned
        Parameters:
        name - : String designating the key in the set
        enumClass - : Class designating the class of the value associated with the key in the set
        defaultValue - : designating the value by default
        Returns:
        Enum
      • getObject

        public final <A> A getObject​(java.lang.String name,
                                     java.lang.Class<A> type)
      • getList

        public <T> java.util.List<T> getList​(java.lang.String key,
                                             java.lang.Class<T> clazz)
      • getList

        public <T> java.util.List<T> getList​(java.lang.String key,
                                             java.lang.Class<T> clazz,
                                             java.util.List<T> defaultValue)
      • getSet

        public <T> java.util.Set<T> getSet​(java.lang.String key,
                                           java.lang.Class<T> clazz)
      • getSet

        public <T> java.util.Set<T> getSet​(java.lang.String key,
                                           java.lang.Class<T> clazz,
                                           java.util.Set<T> defaultValue)
      • getEnumList

        public <T extends java.lang.Enum<T>> java.util.List<T> getEnumList​(java.lang.String key,
                                                                           java.lang.Class<T> clazz)
      • getEnumSet

        public <T extends java.lang.Enum<T>> java.util.Set<T> getEnumSet​(java.lang.String key,
                                                                         java.lang.Class<T> clazz)
      • getMap

        public <K,​V> java.util.Map<K,​V> getMap​(java.lang.String key,
                                                           java.lang.Class<K> keyClass,
                                                           java.lang.Class<V> valueClass)
      • getMapOfList

        public <K,​V> java.util.Map<K,​java.util.List<V>> getMapOfList​(java.lang.String key,
                                                                                 java.lang.Class<K> keyClass,
                                                                                 java.lang.Class<V> valueClass)