Class MapUtil
- java.lang.Object
-
- com.github.unafraid.telegrambot.util.MapUtil
-
public final class MapUtil extends java.lang.Object
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleangetBoolean(java.lang.String name)Return the boolean associated to the key put in parameter ("name")booleangetBoolean(java.lang.String name, boolean defaultValue)Return the boolean associated to the key put in parameter ("name").bytegetByte(java.lang.String name)Returns the byte associated to the key put in parameter ("name").bytegetByte(java.lang.String name, byte defaultValue)Returns the int associated to the key put in parameter ("name").doublegetDouble(java.lang.String name)Returns the double associated to the key put in parameter ("name").doublegetDouble(java.lang.String name, float defaultValue)Returns the double associated to the key put in parameter ("name").<T extends java.lang.Enum<T>>
TgetEnum(java.lang.String name, java.lang.Class<T> enumClass)Returns an enumeration of <T> from the set<T extends java.lang.Enum<T>>
TgetEnum(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)floatgetFloat(java.lang.String name)Returns the float associated to the key put in parameter ("name").floatgetFloat(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)intgetInt(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").intgetInteger(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)longgetLong(java.lang.String name)Returns the long associated to the key put in parameter ("name").longgetLong(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> AgetObject(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)shortgetShort(java.lang.String name)Returns the short associated to the key put in parameter ("name").shortgetShort(java.lang.String name, short defaultValue)Returns the short associated to the key put in parameter ("name").java.lang.StringgetString(java.lang.String name)Returns the String associated to the key put in parameter ("name").java.lang.StringgetString(java.lang.String name, java.lang.String defaultValue)Returns the String associated to the key put in parameter ("name").voidmerge(MapUtil newSet)Add a set of couple values in the current setMapUtilput(java.lang.String name, java.lang.Object value)Puts key-value pair inside the internal map, replacing previously existing key
-
-
-
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 setdefaultValue- : 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 setdefaultValue- : 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 setdefaultValue- : 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 setdefaultValue- : 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 setdelimiter-- 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 setdefaultValue- : 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 setdefaultValue- : 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 setdefaultValue- : 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 setdefaultValue- : 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 setenumClass- : 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 setenumClass- : Class designating the class of the value associated with the key in the setdefaultValue- :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)
-
-