public class Hash extends Object
Typical name is getType(Map map, String key, Type...or)
Almost all methods take the varargs or... argument. Only the 0th value is ever used. If present, and the key is not in the map, the or[0] will be returned If not present, and the key is not in the map, a NoSuchKeyException will be thrown
Modifier and Type | Class and Description |
---|---|
static class |
Hash.NoSuchKeyException |
Constructor and Description |
---|
Hash() |
Modifier and Type | Method and Description |
---|---|
static Object |
get(Map<String,?> map,
String key,
boolean mustBePresent)
Get the value for that key (mainly used internally)
|
static boolean |
getBoolean(Map<String,?> map,
String key,
boolean... or)
Return the value for that key, converted to a boolean
|
static double |
getDouble(Map<String,?> map,
String key,
double... or)
Return the value for that key, converted to a double
|
static int |
getInt(Map<String,?> map,
String key,
int... or)
Return the value for that key, converted to a int
|
static List<Object> |
getList(Map<String,Object> map,
String key,
boolean create)
Return the value for that key, converted to a List
|
static Map<String,Object> |
getMap(Map<String,Object> map,
String key,
boolean create)
Return the value for that key, converted to a Map
|
static Object |
getObject(Map<String,?> map,
String key,
Object defaultObject)
Return an Object from the map
|
static String |
getString(Map<String,?> map,
String key) |
static String |
getString(Map<String,?> map,
String key,
String... or)
Return the value for that key, converted to a String
|
public static Object get(Map<String,?> map, String key, boolean mustBePresent)
map
- may be nullkey
- generally non-nullmustBePresent
- if true, and key does not exist, will throw a NoSuchKeyExceptionpublic static boolean getBoolean(Map<String,?> map, String key, boolean... or)
map
- non-nullkey
- generally non-nullor
- optionalpublic static double getDouble(Map<String,?> map, String key, double... or)
map
- non-nullkey
- generally non-nullor
- optionalpublic static int getInt(Map<String,?> map, String key, int... or)
map
- non-nullkey
- generally non-nullor
- optionalpublic static List<Object> getList(Map<String,Object> map, String key, boolean create)
map
- non-nullkey
- generally non-nullcreate
- if true, and key not present, creates new ArrayListpublic static Map<String,Object> getMap(Map<String,Object> map, String key, boolean create)
map
- non-nullkey
- generally non-nullcreate
- if true, and key not present, creates new LinkedHashMappublic static String getString(Map<String,?> map, String key, String... or)
map
- non-nullkey
- generally non-nullor
- optional