Skip to content

Commit

Permalink
FunctionalM.findBy
Browse files Browse the repository at this point in the history
  • Loading branch information
jyrimatti committed Apr 15, 2024
1 parent 3f64479 commit 127f3ab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>fi.solita.utils</groupId>
<artifactId>functional-utils</artifactId>
<version>0.12.49</version>
<version>0.12.50</version>
<build>
<resources>
<resource>
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/fi/solita/utils/functional/FunctionalM.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ public static final <K, V> Option<V> find(K key, Map<? super K, V> map) {
return FunctionalImpl.find(key, map);
}

/**
* @return values in {@code map} whose keys satisfy {@code predicate}.
*/
public static final <K, V> Iterable<V> findBy(Apply<? super K, Boolean> predicate, Map<K, V> map) {
return FunctionalImpl.map(Transformers.<V>right(), FunctionalImpl.filter(Transformers.<K>left().andThen(predicate), map.entrySet()));
}

/**
* @return elements in {@code map} whose entries satisfy {@code predicate}.
*/
Expand Down

0 comments on commit 127f3ab

Please sign in to comment.