-
- All Implemented Interfaces:
public class DataReaderUtility to read data from
Eventdata which is represented asMap<String, Object>in a type safe way.The value of an
Eventdata key can be obtained in multiple ways:- The
DataReader.optXyz(...)methods are typically the best choice for users. These methods return the value as anxyz. If the value is missing or is not anxyz, the method will return a default value. Implicit conversions between types are not performed, except between numeric types. No implicit conversions even between numeric types are performed when reading asMaporList. - The
DataReader.getXyz(...)methods return the value as anxyz. If the value is missing or is not anxyzthe method will throw. Implicit conversions between types are not performed, except between numeric types. No implicit conversions even between numeric types are performed when reading asMaporList.
-
-
Method Summary
Modifier and Type Method Description static <T> Map<String, T>getTypedMap(Class<T> tClass, Map<String, out Object> map, String key)Gets the value for keyfrommapas aMap<String, T>static <T> Map<String, T>optTypedMap(Class<T> tClass, Map<String, out Object> map, String key, Map<String, T> fallback)Gets the value for keyfrommapas aMap<String, T>or returns default valuestatic <T> List<T>getTypedList(Class<T> tClass, Map<String, out Object> map, String key)Gets the value for keyfrommapas aList<T>static <T> List<T>optTypedList(Class<T> tClass, Map<String, out Object> map, String key, List<T> fallback)Gets the value for keyfrommapas aList<T>or returns default valuestatic <T> List<Map<String, T>>getTypedListOfMap(Class<T> tClass, Map<String, out Object> map, String key)Gets the value for keyfrommapas aList<Map<String, T>>static <T> List<Map<String, T>>optTypedListOfMap(Class<T> tClass, Map<String, out Object> map, String key, List<Map<String, T>> fallback)Gets the value for keyfrommapas aList<Map<String, T>>or returns default valuestatic booleangetBoolean(Map<String, out Object> map, String key)Gets the value for keyfrommapas abooleanstatic booleanoptBoolean(Map<String, out Object> map, String key, boolean fallback)Gets the value for keyfrommapas abooleanor returns default valuestatic intgetInt(Map<String, out Object> map, String key)Gets the value for keyfrommapas anintstatic intoptInt(Map<String, out Object> map, String key, int fallback)Gets the value for keyfrommapas anintor returns default valuestatic longgetLong(Map<String, out Object> map, String key)Gets the value for keyfrommapas anlongstatic longoptLong(Map<String, out Object> map, String key, long fallback)Gets the value for keyfrommapas anlongor returns default valuestatic floatgetFloat(Map<String, out Object> map, String key)Gets the value for keyfrommapas anfloatstatic floatoptFloat(Map<String, out Object> map, String key, float fallback)Gets the value for keyfrommapas anfloator returns default valuestatic doublegetDouble(Map<String, out Object> map, String key)Gets the value for keyfrommapas andoublestatic doubleoptDouble(Map<String, out Object> map, String key, double fallback)Gets the value for keyfrommapas andoubleor returns default valuestatic StringgetString(Map<String, out Object> map, String key)Gets the value for keyfrommapas anStringstatic StringoptString(Map<String, out Object> map, String key, String fallback)Gets the value for keyfrommapas aStringor returns default valuestatic Map<String, String>getStringMap(Map<String, out Object> map, String key)Gets the value for keyfrommapas aMap<String, String>static Map<String, String>optStringMap(Map<String, out Object> map, String key, Map<String, String> fallback)Gets the value for keyfrommapas aMap<String, String>or returns default valuestatic List<String>getStringList(Map<String, out Object> map, String key)Gets the value for keyfrommapas aList<String>static List<String>optStringList(Map<String, out Object> map, String key, List<String> fallback)Gets the value for keyfrommapas aList<String>or returns default value-
-
Method Detail
-
getTypedMap
static <T> Map<String, T> getTypedMap(Class<T> tClass, Map<String, out Object> map, String key)
Gets the value for
keyfrommapas aMap<String, T>- Parameters:
tClass- Custom classmap-Mapmap to fetch datakey-Stringkey to fetch
-
optTypedMap
static <T> Map<String, T> optTypedMap(Class<T> tClass, Map<String, out Object> map, String key, Map<String, T> fallback)
Gets the value for
keyfrommapas aMap<String, T>or returns default value- Parameters:
tClass- Custom classmap-Mapmap to fetch datakey-Stringkey to fetchfallback-Map<String, T>value to return in case of failure.
-
getTypedList
static <T> List<T> getTypedList(Class<T> tClass, Map<String, out Object> map, String key)
Gets the value for
keyfrommapas aList<T>- Parameters:
tClass- Custom classmap-Mapmap to fetch datakey-Stringkey to fetch
-
optTypedList
static <T> List<T> optTypedList(Class<T> tClass, Map<String, out Object> map, String key, List<T> fallback)
Gets the value for
keyfrommapas aList<T>or returns default value- Parameters:
tClass- Custom classmap-Mapmap to fetch datakey-Stringkey to fetchfallback-List<T>value to return in case of failure.
-
getTypedListOfMap
static <T> List<Map<String, T>> getTypedListOfMap(Class<T> tClass, Map<String, out Object> map, String key)
Gets the value for
keyfrommapas aList<Map<String, T>>- Parameters:
tClass- Custom classmap-Mapmap to fetch datakey-Stringkey to fetch
-
optTypedListOfMap
static <T> List<Map<String, T>> optTypedListOfMap(Class<T> tClass, Map<String, out Object> map, String key, List<Map<String, T>> fallback)
Gets the value for
keyfrommapas aList<Map<String, T>>or returns default value- Parameters:
tClass- Custom classmap-Mapmap to fetch datakey-Stringkey to fetchfallback-List<Map<String, T>>value to return in case of failure.
-
getBoolean
static boolean getBoolean(Map<String, out Object> map, String key)
Gets the value for
keyfrommapas aboolean- Parameters:
map-Mapmap to fetch datakey-Stringkey to fetch
-
optBoolean
static boolean optBoolean(Map<String, out Object> map, String key, boolean fallback)
Gets the value for
keyfrommapas abooleanor returns default value- Parameters:
map-Mapmap to fetch datakey-Stringkey to fetchfallback-booleanvalue to return in case of failure.
-
getInt
static int getInt(Map<String, out Object> map, String key)
Gets the value for
keyfrommapas anint- Parameters:
map-Mapmap to fetch datakey-Stringkey to fetch
-
optInt
static int optInt(Map<String, out Object> map, String key, int fallback)
Gets the value for
keyfrommapas anintor returns default value- Parameters:
map-Mapmap to fetch datakey-Stringkey to fetchfallback-intvalue to return in case of failure.
-
getLong
static long getLong(Map<String, out Object> map, String key)
Gets the value for
keyfrommapas anlong- Parameters:
map-Mapmap to fetch datakey-Stringkey to fetch
-
optLong
static long optLong(Map<String, out Object> map, String key, long fallback)
Gets the value for
keyfrommapas anlongor returns default value- Parameters:
map-Mapmap to fetch datakey-Stringkey to fetchfallback-longvalue to return in case of failure.
-
getFloat
static float getFloat(Map<String, out Object> map, String key)
Gets the value for
keyfrommapas anfloat- Parameters:
map-Mapmap to fetch datakey-Stringkey to fetch
-
optFloat
static float optFloat(Map<String, out Object> map, String key, float fallback)
Gets the value for
keyfrommapas anfloator returns default value- Parameters:
map-Mapmap to fetch datakey-Stringkey to fetchfallback-floatvalue to return in case of failure.
-
getDouble
static double getDouble(Map<String, out Object> map, String key)
Gets the value for
keyfrommapas andouble- Parameters:
map-Mapmap to fetch datakey-Stringkey to fetch
-
optDouble
static double optDouble(Map<String, out Object> map, String key, double fallback)
Gets the value for
keyfrommapas andoubleor returns default value- Parameters:
map-Mapmap to fetch datakey-Stringkey to fetchfallback-doublevalue to return in case of failure.
-
getString
static String getString(Map<String, out Object> map, String key)
Gets the value for
keyfrommapas anString- Parameters:
map-Mapmap to fetch datakey-Stringkey to fetch
-
optString
static String optString(Map<String, out Object> map, String key, String fallback)
Gets the value for
keyfrommapas aStringor returns default value- Parameters:
map-Mapmap to fetch datakey-Stringkey to fetchfallback-Stringvalue to return in case of failure.
-
getStringMap
static Map<String, String> getStringMap(Map<String, out Object> map, String key)
Gets the value for
keyfrommapas aMap<String, String>- Parameters:
map-Mapmap to fetch datakey-Stringkey to fetch
-
optStringMap
static Map<String, String> optStringMap(Map<String, out Object> map, String key, Map<String, String> fallback)
Gets the value for
keyfrommapas aMap<String, String>or returns default value- Parameters:
map-Mapmap to fetch datakey-Stringkey to fetchfallback-Map<String, String>value to return in case of failure.
-
getStringList
static List<String> getStringList(Map<String, out Object> map, String key)
Gets the value for
keyfrommapas aList<String>- Parameters:
map-Mapmap to fetch datakey-Stringkey to fetch
-
optStringList
static List<String> optStringList(Map<String, out Object> map, String key, List<String> fallback)
Gets the value for
keyfrommapas aList<String>or returns default value- Parameters:
map-Mapmap to fetch datakey-Stringkey to fetchfallback-List<String>value to return in case of failure.
-
-
-
-