List of utility methods to do Map Create
HashMap | createMap_pollutantHourly() create Mapollutant Hourly HashMap<String, String> map = new HashMap<String, String>(); map.put("so2", "SulphurDioxide"); map.put("pm10", "PM10"); map.put("co", "CarbonMonoxide"); map.put("no2", "NitrogenDioxide"); map.put("o3", "Ozone"); return map; |
Map | createMapFor(String... args) create Map For if (args.length % 2 > 0) throw new IllegalArgumentException( "The argument count must be event to account for key/value pairs. You provided " + args.length + " arguments."); Map<String, String> argMap = new HashMap<String, String>(); for (int i = 0; i < args.length; i = i + 2) { argMap.put(args[i], args[i + 1]); return argMap; |
Map | createMapFromArgs(Object... args) create Map From Args Map<String, Object> result = new HashMap<String, Object>(); if (args.length % 2 != 0) throw new IllegalArgumentException("There must be a pair number of arguments"); for (int i = 0; i < args.length; i = i + 2) { String keyArg = (String) args[i]; Object arg = args[i + 1]; result.put(keyArg, arg); return result; |
Map | createMapFromProperties(Properties stringSubstitutionVariables) create Map From Properties HashMap<String, String> map = new HashMap<String, String>(); Set<Entry<Object, Object>> entrySet = stringSubstitutionVariables.entrySet(); for (Entry<Object, Object> entry : entrySet) { map.put((String) entry.getKey(), (String) entry.getValue()); return map; |
Map | createMapFromWebsiteList(String[] websiteList) create Map From Website List Map<String, Boolean> webMap = new HashMap<String, Boolean>(); for (String website : websiteList) { webMap.put(website, true); return webMap; |
Map | map(final Entry map final HashMap<K, V> map = new HashMap<K, V>(entries.length); for (final Entry<K, V> entry : entries) { map.put(entry.getKey(), entry.getValue()); return Collections.unmodifiableMap(map); |
Map | map(final Object... keysAndValues) map return new HashMap<String, Object>() { for (int i = 0; i < keysAndValues.length; i += 2) { put(String.valueOf(keysAndValues[i]), keysAndValues[i + 1]); }; |
Map | map(final Properties props) map final Map<String, Object> map = new HashMap<String, Object>(); for (final Map.Entry<Object, Object> entry : props.entrySet()) { map.put((String) entry.getKey(), entry.getValue()); return map; |
Map | map(int initialCapacity) Constructs a Map capable of holding a specified number of elements. return new HashMap<K, V>(initialCapacity); |
Map | map(K key, V value) Reduces overhead compared to the far more advanced #map(Object) . Map<K, V> map = new HashMap<>(); map.put(key, value); return map; |