List of usage examples for java.util Map entrySet
Set<Map.Entry<K, V>> entrySet();
From source file:Main.java
public static String convert2XML_(Map<String, String> params) { StringBuffer sb = new StringBuffer("<xml>"); try {//from w ww . ja v a 2s. c om Iterator it = params.entrySet().iterator(); while (it.hasNext()) { Entry entry = (Entry) it.next(); sb.append("<![CDATA[" + entry.getValue() + "]]"); sb.append(entry.getValue()); sb.append("</" + entry.getKey() + ">"); } sb.append("<CreateTime>").append(new Date().getTime()).append("</CreateTime>"); sb.append("</xml>"); } catch (Exception e) { e.printStackTrace(); } return sb.toString(); }
From source file:com.netflix.spinnaker.orca.clouddriver.tasks.providers.aws.AmazonImageFinder.java
static Map<String, String> prefixTags(Map<String, String> tags) { return tags.entrySet().stream().collect(toMap(entry -> "tag:" + entry.getKey(), Map.Entry::getValue)); }
From source file:se.uu.it.cs.recsys.dataloader.correction.CourseSelectionRecourseCorrecter.java
private static String replaceWrongCourseNameWithCorrect(String line, Map<String, String> wrongToCorrect) { StringBuilder lineCopy = new StringBuilder(line); wrongToCorrect.entrySet().stream().forEach(entry -> { if (lineCopy.toString().contains(entry.getKey())) { String contentCopy = lineCopy.toString(); String replacedCopy = contentCopy.replace(entry.getKey(), entry.getValue()); lineCopy.setLength(0);/*from w w w.j a va 2 s . c o m*/ lineCopy.append(replacedCopy); } }); return lineCopy.toString(); }
From source file:Main.java
private static StringBuffer getParamString(Map<String, String> params) { StringBuffer result = new StringBuffer(); Iterator<Map.Entry<String, String>> iterator = params.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry<String, String> param = iterator.next(); String key = param.getKey(); String value = param.getValue(); result.append(key).append('=').append(value); if (iterator.hasNext()) { result.append('&'); }/*from w w w . j av a 2 s. c o m*/ } return result; }
From source file:Main.java
private static StringBuffer getParamString(Map<String, Object> params) { StringBuffer result = new StringBuffer(); Iterator<Map.Entry<String, Object>> iterator = params.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry<String, Object> param = iterator.next(); String key = param.getKey(); Object value = param.getValue(); result.append(key).append('=').append(value); if (iterator.hasNext()) { result.append('&'); }//ww w . j a va2s .c om } return result; }
From source file:Main.java
/** * Returns a new map with all entries of the input map except those which have a value of null.<p> * /*from w w w .j av a 2s . co m*/ * @param <A> the key type of the map * @param <B> the value type of the map * @param map the input map * * @return a map with all null entries removed */ public static <A, B> Map<A, B> removeNullEntries(Map<A, B> map) { HashMap<A, B> result = new HashMap<A, B>(); for (Map.Entry<A, B> entry : map.entrySet()) { if (entry.getValue() != null) { result.put(entry.getKey(), entry.getValue()); } } return result; }
From source file:Main.java
/** * Reverses a map (switches key and value types). * * @param <K> the key type/* w ww . ja v a2 s .c om*/ * @param <V> the value type * @param map the map * * @return the reversed map */ public static <K, V> Map<V, K> reverse(final Map<K, V> map) { final Map<V, K> reversed = new HashMap<V, K>(map.size()); for (final Entry<K, V> e : map.entrySet()) { reversed.put(e.getValue(), e.getKey()); } return reversed; }
From source file:com.adeptj.runtime.server.IdentityManagers.java
static Account verifyCredentials(Map<String, List<String>> userRolesMapping, String id, Credential credential) { return userRolesMapping.entrySet().stream() .filter(entry -> doVerifyCredentials(entry.getKey(), id, credential)) .map(entry -> new SimpleAccount(new SimplePrincipal(entry.getKey()), new HashSet<>(entry.getValue()))) .findFirst().orElse(null);/* w w w. ja va2 s. c o m*/ }
From source file:Main.java
public static <T> void incrementValueByIndex(final Map<T, Integer> map, final List<Integer> keys, final int delta) { for (Entry<T, Integer> entry : map.entrySet()) { int val = entry.getValue(); entry.setValue(val + delta * getLowestInsertionPoint(keys, val)); }//from w w w. j av a 2 s . co m }
From source file:Main.java
public static Map<String, String> convertMap(Map<String, String[]> srcMap) { Map<String, String> aimMap = new HashMap<String, String>(); for (Entry<String, String[]> entry : srcMap.entrySet()) { String[] srcValue = entry.getValue(); String aimValue = srcValue != null && srcValue.length > 0 ? srcValue[0] : null; aimMap.put(entry.getKey(), aimValue); }//from www .j a va 2 s . c o m return aimMap; }