Get a List value from a Map @param map Source map @param key The key @return The List value @throws IllegalArgumentException If value is not a List and cannot be converted
(Map<String, Object> map, String key)
| 348 | * @throws IllegalArgumentException If value is not a List and cannot be converted |
| 349 | */ |
| 350 | @SuppressWarnings("unchecked") |
| 351 | public static <T> List<T> getList(Map<String, Object> map, String key) throws IllegalArgumentException { |
| 352 | Object value = map == null || key == null ? null : map.get(key); |
| 353 | if (value == null) { |
| 354 | return null; |
| 355 | } |
| 356 | |
| 357 | if (value instanceof List) { |
| 358 | return (List<T>) value; |
| 359 | } |
| 360 | |
| 361 | throw new IllegalArgumentException("Value for key '" + key + "' is not a List: " + value.getClass().getName()); |
| 362 | } |
| 363 | |
| 364 | /** |
| 365 | * Get an int value from a Map |