Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Lazy.filter lazy #2178

Closed
danieldietrich opened this issue Nov 25, 2017 · 0 comments
Closed

Make Lazy.filter lazy #2178

danieldietrich opened this issue Nov 25, 2017 · 0 comments

Comments

@danieldietrich
Copy link
Contributor

danieldietrich commented Nov 25, 2017

See also #1861 and this discussion.

- public Option<T> filter(Predicate<? super T> predicate) {
-     final T v = get();
-     return predicate.test(v) ? Option.some(v) : Option.none();
+ public Lazy<Option<T>> filter(Predicate<? super T> predicate) {
+    Objects.requireNonNull(predicate, "predicate is null");
+    return map(t -> Option.some(t).filter(predicate));
}

However, there is one thing that currently hinders us from doing so: The return type is not compatible with Value.filter anymore.

Our options are:

  • leave Lazy.filter as-is (i.e. not performing this change)
  • change Value.filter (or remove it, like flatMap)

Update: No problem! Value does not have filter anymore :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant