public <NK, NV> Map<NK, NV> transform($.Function<K, NK> keyTransformer, $.Function<V, NV> valueTransformer) { Map<NK, NV> newMap = C.newMap(); for (java.util.Map.Entry<K, V> entry : entrySet()) { newMap.put(keyTransformer.apply(entry.getKey()), valueTransformer.apply(entry.getValue())); } return newMap; }
this.intermediates = new HashSet<>(); this.specialMapping = specialMapping; this.specialMappingsReversed = C.Map(specialMapping).flipped(); for (Map.Entry<String, String> entry : specialMapping.entrySet()) { String s = entry.getKey();
for (Map.Entry<String, Object> cellData : data.entrySet()) { String key = cellData.getKey(); int cellId = colIndex.get(key); Cell cell = row.createCell(cellId); CellStyle style = fieldStyles.get(Keyword.of(key));
params.put(u ? "_request" : "request", request); params.put("__request", request); params.put(u ? "_response" : "response", SessionManager.response()); HttpSession httpSession = request.getSession(false); params.put(u ? "_httpSession" : "httpSession", httpSession); if (enableSessionManager) { params.put(u ? "_session" : "session", Session.current()); params.put(u ? "_flash" : "flash", Flash.current()); params.put(u ? "_userAgent" : "userAgent", UADetector.get());
this.intermediates = new HashSet<>(); this.specialMapping = specialMapping; this.specialMappingsReversed = C.Map(specialMapping).flipped(); for (Map.Entry<String, String> entry : specialMapping.entrySet()) { String s = entry.getKey();
/** * Create a immutable {@link Map} from elements specified in an array. * <p>Example</p> * <pre> * Map<String, Integer> scores = C.map("Tom", 80, "Peter", 93, ...); * </pre> * <p>The above code will create an immutable Map with the following entries</p> * <ul> * <li>(Tom, 80)</li> * <li>(Peter, 93)</li> * <li>...</li> * </ul> * <p><b>Note</b> the array size must be an even number, otherwise {@link IndexOutOfBoundsException} * will be thrown out</p> * @param args the argument array specifies the entries * @param <K> the key type * @param <V> the value type * @return an immutable map contains of specified entries * @see #newMap(Object...) */ public static <K, V> Map<K, V> Map(Object... args) { if (null == args || args.length == 0) { return Nil.EMPTY_MAP; } return new Map<>(true, args); }
/** * Create an new {@link Map} from an array of elements. * <p>Example</p> * <pre> * Map<String, Integer> scores = C.newMap("Tom", 80, "Peter", 93, ...); * </pre> * <p>The above code will create a Map with the following entries</p> * <ul> * <li>(Tom, 80)</li> * <li>(Peter, 93)</li> * <li>...</li> * </ul> * <p><b>Note</b> the array size must be an even number, otherwise {@link IndexOutOfBoundsException} * will be thrown out</p> * @param args the argument array specifies the entries * @param <K> the key type * @param <V> the value type * @return a map contains of specified entries * @see #Map(Object...) */ @SuppressWarnings("unchecked") public static <K, V> Map<K, V> newMap(Object... args) { return new Map(false, args); }
/** * Create an new {@link Map} from an array of elements. * <p>Example</p> * <pre> * Map<String, Integer> scores = C.newMap("Tom", 80, "Peter", 93, ...); * </pre> * <p>The above code will create a Map with the following entries</p> * <ul> * <li>(Tom, 80)</li> * <li>(Peter, 93)</li> * <li>...</li> * </ul> * <p><b>Note</b> the array size must be an even number, otherwise {@link IndexOutOfBoundsException} * will be thrown out</p> * @param args the argument array specifies the entries * @param <K> the key type * @param <V> the value type * @return a map contains of specified entries * @see #Map(Object...) */ @SuppressWarnings("unchecked") public static <K, V> Map<K, V> newMap(Object... args) { return new Map(false, args); }
/** * Create a immutable {@link Map} from elements specified in an array. * <p>Example</p> * <pre> * Map<String, Integer> scores = C.map("Tom", 80, "Peter", 93, ...); * </pre> * <p>The above code will create an immutable Map with the following entries</p> * <ul> * <li>(Tom, 80)</li> * <li>(Peter, 93)</li> * <li>...</li> * </ul> * <p><b>Note</b> the array size must be an even number, otherwise {@link IndexOutOfBoundsException} * will be thrown out</p> * @param args the argument array specifies the entries * @param <K> the key type * @param <V> the value type * @return an immutable map contains of specified entries * @see #newMap(Object...) */ public static <K, V> Map<K, V> Map(Object... args) { if (null == args || args.length == 0) { return Nil.EMPTY_MAP; } return new Map<>(true, args); }
private void createHeaderRow(Sheet sheet, C.Map<String, Integer> colIndex) { headerRow = sheet.createRow(0); C.Map<Integer, String> flipped = colIndex.flipped(); int max = maxColId.get(); for (int i = 0; i < max; ++i) { Cell cell = headerRow.createCell(i); String label = flipped.get(i); boolean mapped = false; if (null != headerMapping) { String newLabel = headerMapping.get(label); if (null != newLabel) { label = newLabel; mapped = true; } } if (!mapped && null != headerTransformer) { label = headerTransformer.apply(label); } cell.setCellValue(label); } }
/** * Loop through this map on each key/value pair, apply them to the function specified * @param indexedVisitor the function that takes argument of (key, value) pair * @return this map */ public Map<K, V> forEach(IndexedVisitor<? super K, ? super V> indexedVisitor) { for (java.util.Map.Entry<K, V> entry: entrySet()) { try { indexedVisitor.apply(entry.getKey(), entry.getValue()); } catch (NotAppliedException e) { // ignore } } return this; }
/** * Loop through this map on each key/value pair, apply them to the function specified * @param indexedVisitor the function that takes argument of (key, value) pair * @return this map */ public Map<K, V> forEach(IndexedVisitor<? super K, ? super V> indexedVisitor) { for (java.util.Map.Entry<K, V> entry: entrySet()) { try { indexedVisitor.apply(entry.getKey(), entry.getValue()); } catch (NotAppliedException e) { // ignore } } return this; }
public static <K, V> Map<K, V> Map(boolean readOnly, java.util.Map<K, V> map) { return new Map(readOnly, map); }
public static <K, V> Map<K, V> Map(boolean readOnly, java.util.Map<K, V> map) { return new Map(readOnly, map); }
/** * Create an immutable {@link java.util.Map} from existing {@link java.util.Map} * @param map the map from which entries will be put into the new immutable map * @param <K> the key type * @param <V> the value type * @return an immutable map of the existing map */ public static <K, V> Map<K, V> Map(java.util.Map<? extends K, ? extends V> map) { if (null == map) { return Nil.EMPTY_MAP; } return new Map(true, map); }
/** * Create an immutable {@link java.util.Map} from existing {@link java.util.Map} * @param map the map from which entries will be put into the new immutable map * @param <K> the key type * @param <V> the value type * @return an immutable map of the existing map */ public static <K, V> Map<K, V> Map(java.util.Map<? extends K, ? extends V> map) { if (null == map) { return Nil.EMPTY_MAP; } return new Map(true, map); }
@Override public <V> C.Map<T, V> toMapByKey(Lang.Function<? super T, ? extends V> valExtractor) { C.Map<T, V> map = C.newMap(); for (T v : this) { map.put(v, valExtractor.apply(v)); } return map; }
@Override public <K> C.Map<K, T> toMapByVal(Lang.Function<? super T, ? extends K> keyExtractor) { C.Map<K, T> map = C.newMap(); for (T v : this) { map.put(keyExtractor.apply(v), v); } return map; }
@Override public void putAll(java.util.Map<? extends K, ? extends V> m) { ensureWritable(); _m.putAll(m); }