Skip to content

Commit fa6261e

Browse files
committed
Adding more javadocs to MapLens
1 parent 4f93047 commit fa6261e

File tree

1 file changed

+9
-4
lines changed
  • src/main/java/com/jnape/palatable/lambda/lens/lenses

1 file changed

+9
-4
lines changed

src/main/java/com/jnape/palatable/lambda/lens/lenses/MapLens.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ public static <K, V> Lens.Simple<Map<K, V>, Collection<V>> values() {
128128
/**
129129
* A lens that focuses on the inverse of a map (keys and values swapped). In the case of multiple equal values
130130
* becoming keys, the last one wins.
131+
* <p>
132+
* Note that this lens is very likely to NOT be lawful, since "you get back what you put in" will fail for any keys
133+
* that map to the same value.
131134
*
132135
* @param <K> the key type
133136
* @param <V> the value type
@@ -149,9 +152,11 @@ public static <K, V> Lens.Simple<Map<K, V>, Map<V, K>> inverted() {
149152
/**
150153
* A lens that focuses on a map while mapping its values with the mapping function.
151154
* <p>
152-
* Note that this lens is NOT lawful, since "you get back what you put in" fails for all values <code>B</code> that
153-
* do not map from the current values in <code>S</code> (new mappings cannot be preserved as the inversion of
154-
* <code>fn</code> is not known).
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.
155160
*
156161
* @param fn the mapping function
157162
* @param <K> the key type
@@ -183,7 +188,7 @@ public static <K, V, V2> Lens.Simple<Map<K, V>, Map<K, V2>> mappingValues(Functi
183188
* @param iso the mapping {@link Iso}
184189
* @param <K> the key type
185190
* @param <V> the unfocused map value type
186-
* @param <V2> the focused map value types
191+
* @param <V2> the focused map value type
187192
* @return a lens that focuses on a map while mapping its values
188193
*/
189194
public static <K, V, V2> Lens.Simple<Map<K, V>, Map<K, V2>> mappingValues(Iso<V, V, V2, V2> iso) {

0 commit comments

Comments
 (0)