List of usage examples for java.util Map get
V get(Object key);
From source file:Main.java
public static <K, V> Set<V> lookup(Map<K, V> map, Collection<K> keys) { Set<V> result = new LinkedHashSet<V>(); for (K key : keys) { V e = map.get(key); if (e != null) { result.add(e);/* www . j a v a 2 s . co m*/ } } return result; }
From source file:io.gromit.uaparser.model.Device.java
/** * From map.//w ww . jav a2s. c o m * * @param m * the m * @return the device */ public static Device fromMap(Map<String, String> m) { return new Device(m.get("family"), m.get("brand"), m.get("model")); }
From source file:Main.java
/** * Make a list map immutable./*from w w w .j a v a 2s .com*/ * * @param listMap * the list map in input. * @return the immutable list map. */ public static <C, E> Map<C, List<E>> makeListMapImmutable(Map<C, List<E>> listMap) { for (C key : listMap.keySet()) { listMap.put(key, Collections.unmodifiableList(listMap.get(key))); } return Collections.unmodifiableMap(listMap); }
From source file:Main.java
public static URL getLargestImageURL(Map<String, URL> imageURLs) { if (imageURLs == null) { return null; }/*w ww . ja va 2s . co m*/ URL result = imageURLs.get("large"); if (result != null) { return result; } result = imageURLs.get("medium"); if (result != null) { return result; } return imageURLs.get("small"); }
From source file:org.eclipse.swordfish.core.configuration.xml.SaxParsingPrototype.java
private static void putElement(Map<String, List<String>> props, String key, String value) { if (props.containsKey(key)) { props.get(key).add(value); } else {// w w w . j av a 2 s . c om List<String> list = new LinkedList<String>(); list.add(value); props.put(key, list); } }
From source file:com.common.server.AppLicenceUtil.java
public static int userCount() throws Exception { Map map = getLicence(); String userCount = (String) map.get("userCount"); if (userCount != null) { int count = Integer.valueOf(userCount).intValue(); return count; } else//from www. j ava 2 s .c o m return 0; }
From source file:com.salesmanager.core.util.LanguageUtil.java
public static String getLanguageStringCode(int lang) { Map langmap = RefCache.getLanguageswithindex(); Language l = (Language) langmap.get(lang); if (l != null) { return l.getCode(); } else {//from w w w .j a v a 2 s . c om return Constants.ENGLISH_CODE; } }
From source file:Main.java
public static Object get(String key) { Map<String, Object> threadCache = threadCacheHolder.get(); if (threadCache == null) { return null; }//from w ww .j a va2 s . com return threadCache.get(key); }
From source file:Main.java
/** * /* w ww.j av a2 s . c o m*/ * pre : resultSet must be a valid List<Map> <br> * post : a Map<columnName, List of same columnName> * * @param <K> * @param resultSet * result set from sql. no need order by * @param columnName * the column name that need to group by * @return null if resultSet is null */ @SuppressWarnings("rawtypes") public static <K> Map<K, List<Map>> sqlMapListToMap(List<Map> resultSet, String columnName) { if (resultSet == null) return null; Map<K, List<Map>> rs = new HashMap<K, List<Map>>(); for (Map<?, ?> map : resultSet) { K colValue = (K) map.get(columnName); List<Map> inMap = rs.get(colValue); if (inMap == null) inMap = new ArrayList<Map>(); inMap.add(map); rs.put(colValue, inMap); } return rs; }
From source file:Main.java
/** * Returns a {@link Map} mapping each unique element in the given * {@link Iterable} to an {@link Integer} representing the number * of occurrences of that element in the {@link Iterable}. * <p/>/*from ww w .j a v a 2 s .c om*/ * Only those elements present in the Iterable will appear as * keys in the map. * * @param iterable the collection to get the cardinality map for, must not be null * @return the populated cardinality map */ public static <E> Map<E, java.lang.Integer> getCardinalityMap(final Iterable<E> iterable) { Map<E, Integer> count = new HashMap<E, Integer>(); for (E obj : iterable) { Integer c = count.get(obj); if (c == null) { count.put(obj, INTEGER_ONE); } else { count.put(obj, c + 1); } } return count; }