List of usage examples for java.util Map entrySet
Set<Map.Entry<K, V>> entrySet();
From source file:com.mirth.connect.util.BeanUtil.java
public static void setProperties(Object bean, Map<String, String> properties) { for (Entry<String, String> entry : properties.entrySet()) { try {//from w ww .ja va 2 s . c o m BeanUtils.setProperty(bean, entry.getKey(), entry.getValue()); } catch (Exception e) { logger.error("Failed to set object property '" + entry.getKey() + "'", e); } } }
From source file:MyComparator.java
public static Map<String, Integer> sortByComparator(Map<String, Integer> unsortMap) { List<Entry<String, Integer>> list = new LinkedList<Entry<String, Integer>>(unsortMap.entrySet()); Collections.sort(list, new MyComparator()); Map<String, Integer> sortedMap = new LinkedHashMap<String, Integer>(); for (Entry<String, Integer> entry : list) { sortedMap.put(entry.getKey(), entry.getValue()); }// ww w . j ava 2s .co m return sortedMap; }
From source file:Main.java
/** * Utility method to extract CTS result from test metrics * @param testMetrics/* ww w. j av a2 s. co m*/ * @return result or null if not found */ public static String getCtsResultFromMetrics(Map<String, String> testMetrics) { for (Map.Entry<String, String> entry : testMetrics.entrySet()) { if (CTS_RESULT_KEY.equals(entry.getKey())) { return entry.getValue(); } } return null; }
From source file:Main.java
private static String buildQueryString(String method, Map<String, String> args) { String qry = buildQueryString(method); Iterator it = args.entrySet().iterator(); while (it.hasNext()) { String key = (String) it.next(); String val = args.get(key); qry = qry.concat("?").concat(key).concat("=").concat(val); }//from w w w.j av a2 s . c o m return qry; }
From source file:Main.java
public static boolean mapMatchesFields(Map<String, Object> baseMap, Map<String, Object> compareMap) { for (Map.Entry<String, Object> entry : compareMap.entrySet()) { Object compareObj = compareMap.get(entry.getKey()); Object baseObj = baseMap.get(entry.getKey()); if (compareObj == null) { if (baseObj != null) return false; } else {/*from w w w . j ava 2 s .c o m*/ if (!compareObj.equals(baseObj)) return false; } } return true; }
From source file:Main.java
public static <K, V extends Comparable<? super V>> Map<K, V> sortByValue(Map<K, V> map) { List<Map.Entry<K, V>> list = new LinkedList<Map.Entry<K, V>>(map.entrySet()); Collections.sort(list, new Comparator<Map.Entry<K, V>>() { public int compare(Entry<K, V> o1, Entry<K, V> o2) { return (o2.getValue()).compareTo(o1.getValue()); }// www.j a v a 2 s . c om }); Map<K, V> result = new LinkedHashMap<K, V>(); for (Map.Entry<K, V> entry : list) { result.put(entry.getKey(), entry.getValue()); } return result; }
From source file:Main.java
public static <K, V> Map<K, V> clone(Map<K, V> map1) { Map<K, V> map2 = new HashMap<K, V>(map1.size()); for (Map.Entry<K, V> e : map1.entrySet()) { map2.put(e.getKey(), e.getValue()); }// w ww . j av a 2 s . c o m return map2; }
From source file:Main.java
/** * Update texts for map of textButton views. * @param views//from w ww . jav a2s . c o m * @param texts */ public static void uTextBtn(Map<Integer, Button> views, Map<Integer, String> texts) { for (Entry<Integer, Button> entry : views.entrySet()) { Button button = entry.getValue(); button.setText(texts.get(entry.getKey())); } }
From source file:Main.java
public static String getInclude(Map<String, String> param) { String include = ""; for (Map.Entry<String, String> entry : param.entrySet()) { if (TextUtils.equals(entry.getKey(), "include")) { include = entry.getValue();//w w w .jav a 2 s .co m break; } } return include; }
From source file:Main.java
private static HttpURLConnection addHeaders(HttpURLConnection urlConnection, Map<String, String> headers) { try {/* w w w . j a v a 2 s. co m*/ for (Map.Entry<String, String> entry : headers.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); urlConnection.setRequestProperty(key, value); } } catch (Exception ex) { Log.e("addHeader ", ex.getMessage()); } return urlConnection; }