Class MapUtil

java.lang.Object
com.github.unafraid.telegrambot.util.MapUtil

public final class MapUtil extends Object
  • Constructor Details

    • MapUtil

      public MapUtil()
    • MapUtil

      public MapUtil(Map<String,Object> map)
  • Method Details

    • getInternalMap

      public final Map<String,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(String name, Object value)
      Puts key-value pair inside the internal map, replacing previously existing key
      Parameters:
      name - String designating the key in the set
      value - value associated to the key
      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(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(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(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(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(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(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(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(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(String name, 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 - the delimiter
      Returns:
      int[] : value associated to the key
    • getFloatArray

      public float[] getFloatArray(String name, String delimiter)
    • getLong

      public long getLong(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(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(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(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(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(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 String getString(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 String getString(String name, 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 Enum<T>> T getEnum(String name, 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 of type T
    • getEnum

      public <T extends Enum<T>> T getEnum(String name, 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 - : T designating the value by default
      Returns:
      enum of type T
    • getObject

      public final <A> A getObject(String name, Class<A> type)
    • getList

      public <T> List<T> getList(String key, Class<T> clazz)
    • getList

      public <T> List<T> getList(String key, Class<T> clazz, List<T> defaultValue)
    • getSet

      public <T> Set<T> getSet(String key, Class<T> clazz)
    • getSet

      public <T> Set<T> getSet(String key, Class<T> clazz, Set<T> defaultValue)
    • getEnumList

      public <T extends Enum<T>> List<T> getEnumList(String key, Class<T> clazz)
    • getEnumSet

      public <T extends Enum<T>> Set<T> getEnumSet(String key, Class<T> clazz)
    • getMap

      public <K, V> Map<K,V> getMap(String key, Class<K> keyClass, Class<V> valueClass)
    • getMapOfList

      public <K, V> Map<K,List<V>> getMapOfList(String key, Class<K> keyClass, Class<V> valueClass)