@Override public Map<C, V2> apply(Map<C, V1> row) { return Maps.transformValues(row, function); } };
@Override public Map<R, V2> apply(Map<R, V1> column) { return Maps.transformValues(column, function); } };
@Override public Map<C, Map<R, V2>> columnMap() { Function<Map<R, V1>, Map<R, V2>> columnFunction = new Function<Map<R, V1>, Map<R, V2>>() { @Override public Map<R, V2> apply(Map<R, V1> column) { return Maps.transformValues(column, function); } }; return Maps.transformValues(fromTable.columnMap(), columnFunction); } }
@Override public Map<R, Map<C, V>> rowMap() { Function<Map<C, V>, Map<C, V>> wrapper = unmodifiableWrapper(); return Collections.unmodifiableMap(Maps.transformValues(super.rowMap(), wrapper)); }
@Override public Map<R, Map<C, V2>> rowMap() { Function<Map<C, V1>, Map<C, V2>> rowFunction = new Function<Map<C, V1>, Map<C, V2>>() { @Override public Map<C, V2> apply(Map<C, V1> row) { return Maps.transformValues(row, function); } }; return Maps.transformValues(fromTable.rowMap(), rowFunction); }
private Map<String, ImmutableMultiset<String>> parametersAsMap() { return Maps.transformValues( parameters.asMap(), new Function<Collection<String>, ImmutableMultiset<String>>() { @Override public ImmutableMultiset<String> apply(Collection<String> input) { return ImmutableMultiset.copyOf(input); } }); }
@Override public Map<C, Map<R, V>> columnMap() { Function<Map<R, V>, Map<R, V>> wrapper = unmodifiableWrapper(); return Collections.unmodifiableMap(Maps.transformValues(super.columnMap(), wrapper)); }
@Override public SortedMap<R, Map<C, V>> rowMap() { Function<Map<C, V>, Map<C, V>> wrapper = unmodifiableWrapper(); return Collections.unmodifiableSortedMap(Maps.transformValues(delegate().rowMap(), wrapper)); }
@Override protected Map<String, String> create(Entry<String, String>[] entries) { Map<String, String> map = Maps.newLinkedHashMap(); for (Entry<String, String> entry : entries) { map.put(entry.getKey(), encode(entry.getValue())); } return Maps.transformValues(map, DECODE_FUNCTION); } })
@Override protected Map<String, String> makePopulatedMap() { Map<String, Integer> underlying = Maps.newHashMap(); underlying.put("a", 1); underlying.put("b", 2); underlying.put("c", 3); return Maps.transformValues(underlying, Functions.toStringFunction()); }
public void testTransformValues() { Map<String, Integer> map = ImmutableMap.of("a", 4, "b", 9); Map<String, Double> transformed = transformValues(map, SQRT_FUNCTION); assertEquals(ImmutableMap.of("a", 2.0, "b", 3.0), transformed); }
@Override protected SortedMap<String, String> makePopulatedMap() { SortedMap<String, Integer> underlying = Maps.newTreeMap(); underlying.put("a", 1); underlying.put("b", 2); underlying.put("c", 3); return Maps.transformValues(underlying, Functions.toStringFunction()); } }
@Override protected SortedMap<String, String> create(Entry<String, String>[] entries) { SortedMap<String, String> map = new NonNavigableSortedMap(); for (Entry<String, String> entry : entries) { map.put(entry.getKey(), encode(entry.getValue())); } return Maps.transformValues(map, DECODE_FUNCTION); } })
public void testTransformEmptyMapEquality() { Map<String, String> map = Maps.transformValues(ImmutableMap.<String, Integer>of(), Functions.toStringFunction()); assertMapsEqual(Maps.newHashMap(), map); }
public void testTransformSingletonMapEquality() { Map<String, String> map = Maps.transformValues(ImmutableMap.of("a", 1), Functions.toStringFunction()); Map<String, String> expected = ImmutableMap.of("a", "1"); assertMapsEqual(expected, map); assertEquals(expected.get("a"), map.get("a")); }
public void testTransformRemoveEntry() { Map<String, Integer> underlying = Maps.newHashMap(); underlying.put("a", 1); Map<String, String> map = Maps.transformValues(underlying, Functions.toStringFunction()); assertEquals("1", map.remove("a")); assertNull(map.remove("b")); }
@Override protected Map<String, String> makeEmptyMap() { Map<String, Integer> underlying = Maps.newHashMap(); return Maps.transformValues( new UnmodifiableIteratorMap<String, Integer>(underlying), Functions.toStringFunction()); }
public void testTransformIdentityFunctionEquality() { Map<String, Integer> underlying = ImmutableMap.of("a", 1); Map<String, Integer> map = Maps.transformValues(underlying, Functions.<Integer>identity()); assertMapsEqual(underlying, map); }
public void testTransformIdentityFunctionEquality() { Map<String, Integer> underlying = ImmutableMap.of("a", 1); Map<String, Integer> map = Maps.transformValues(underlying, Functions.<Integer>identity()); assertMapsEqual(underlying, map); }
public void testTransformRemoveEntry() { Map<String, Integer> underlying = Maps.newHashMap(); underlying.put("a", 1); Map<String, String> map = Maps.transformValues(underlying, Functions.toStringFunction()); assertEquals("1", map.remove("a")); assertNull(map.remove("b")); }