|
12 | 12 | import java.util.HashSet;
|
13 | 13 | import java.util.Map;
|
14 | 14 | import java.util.Set;
|
15 |
| -import java.util.function.Function; |
16 | 15 |
|
17 | 16 | import static com.jnape.palatable.lambda.adt.Maybe.maybe;
|
18 |
| -import static com.jnape.palatable.lambda.functions.builtin.fn2.Eq.eq; |
19 | 17 | import static com.jnape.palatable.lambda.functions.builtin.fn2.Map.map;
|
20 | 18 | import static com.jnape.palatable.lambda.functions.builtin.fn2.ToCollection.toCollection;
|
21 | 19 | import static com.jnape.palatable.lambda.functions.builtin.fn2.ToMap.toMap;
|
@@ -149,36 +147,6 @@ public static <K, V> Lens.Simple<Map<K, V>, Map<V, K>> inverted() {
|
149 | 147 | });
|
150 | 148 | }
|
151 | 149 |
|
152 |
| - /** |
153 |
| - * A lens that focuses on a map while mapping its values with the mapping function. |
154 |
| - * <p> |
155 |
| - * Note that this lens is very likely to NOT be lawful, since "you get back what you put in" will fail for all |
156 |
| - * values <code>B</code> that do not map from the current values in <code>S</code> (new mappings cannot be |
157 |
| - * preserved as the inversion of <code>fn</code> is not known). Furthermore, if <code>fn</code> is injective |
158 |
| - * (multiple <code>V</code>s map to the same <code>V2</code>), this lens will also not be lawful for similar reasons |
159 |
| - * as stated above. |
160 |
| - * |
161 |
| - * @param fn the mapping function |
162 |
| - * @param <K> the key type |
163 |
| - * @param <V> the unfocused map value type |
164 |
| - * @param <V2> the focused map value types |
165 |
| - * @return a lens that focuses on a map while mapping its values |
166 |
| - * @deprecated in favor of the lawful (and far more rational) {@link MapLens#mappingValues(Iso)} |
167 |
| - */ |
168 |
| - @Deprecated |
169 |
| - public static <K, V, V2> Lens.Simple<Map<K, V>, Map<K, V2>> mappingValues(Function<? super V, ? extends V2> fn) { |
170 |
| - return simpleLens(m -> toMap(HashMap::new, map(t -> t.biMapR(fn), map(Tuple2::fromEntry, m.entrySet()))), |
171 |
| - (s, b) -> { |
172 |
| - Set<K> retainKeys = Filter.<Map.Entry<K, V>>filter(kv -> eq(fn.apply(kv.getValue()), b.get(kv.getKey()))) |
173 |
| - .andThen(map(Map.Entry::getKey)) |
174 |
| - .andThen(toCollection(HashSet::new)) |
175 |
| - .apply(s.entrySet()); |
176 |
| - Map<K, V> copy = new HashMap<>(s); |
177 |
| - copy.keySet().retainAll(retainKeys); |
178 |
| - return copy; |
179 |
| - }); |
180 |
| - } |
181 |
| - |
182 | 150 | /**
|
183 | 151 | * A lens that focuses on a map while mapping its values with the mapping {@link Iso}.
|
184 | 152 | * <p>
|
|
0 commit comments