List of utility methods to do List to Map
Map | listToMap(final String... strings) list To Map final Map<String, String> map = new LinkedHashMap<>(); final Iterator<String> stringIterator = Arrays.asList(strings).iterator(); while (stringIterator.hasNext()) { final String key = stringIterator.next(); final String value = stringIterator.next(); map.put(key, value); return map; ... |
Map | listToMap(List input) list To Map int sz = input.size(); Map<String, Object> output = new LinkedHashMap<>(); for (int i = 0; i < sz; i++) { output.put("idx_" + i, input.get(i)); return output; |
Map | listToMap(List
Converts a list of two element lists (key, value) into a map. Map<T, T> map = new HashMap<T, T>(list.size()); Iterator<List<T>> i = list.iterator(); while (i.hasNext()) { List<T> l = i.next(); map.put(l.get(0), l.get(1)); return map; |
Map | listToMap(List Puts the entries in list into a Map . Map<A, B> result = new LinkedHashMap<A, B>(); for (Iterator<Map.Entry<A, B>> it = list.iterator(); it.hasNext();) { Map.Entry<A, B> entry = (Map.Entry<A, B>) it.next(); result.put(entry.getKey(), entry.getValue()); return result; |
Map | listToMap(Object... objects) list To Map HashMap map = new HashMap(); Object key = null; for (final Object object : objects) { if (key == null) { key = object; } else { map.put(key, object); key = null; ... |