Skip to content

Commit

Permalink
lens.ofOption to not crash on unexpected nulls
Browse files Browse the repository at this point in the history
  • Loading branch information
jyrimatti committed Dec 10, 2024
1 parent 6d15a31 commit 37088f1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
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.55</version>
<version>0.12.57</version>
<build>
<resources>
<resource>
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/fi/solita/utils/functional/lens/Lens.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ public D apply(D d, final Apply<Option<S>, Option<S>> f) {
return lens.modify(d, new Apply<Option<E>,Option<E>>() {
public Option<E> apply(Option<E> c) {
return c == null ? null : !c.isDefined() ? c : Some(lens2.modify(c.get(), new Apply<S, S>() {
@SuppressWarnings("unchecked")
@Override
public S apply(S t) {
return f.apply(Some(t)).get();
Object ret = f.apply(Some(t));
return ret instanceof Option ? ((Option<S>)ret).get() : (S)ret;
}
}));
};
Expand Down

0 comments on commit 37088f1

Please sign in to comment.