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
Predicate factory classes for Comparable types #429
Comments
Original comment posted by boppenheim@google.com on 2010-09-23 at 04:16 AM This seems reasonable to me. Much more low priority, but if we add these methods, I wonder if it's worth having corresponding methods that take a reference and a Comparator. Seems like it may be useful for working with library code that you can't modify. |
Original comment posted by SeanPFloyd on 2010-09-23 at 04:50 PM I agree, I was going to suggest the same thing. |
Original comment posted by kevinb@google.com on 2010-12-17 at 06:31 AM The way we'll address the main (Comparable) case is that our Range class will implement Predicate. Ranges will support the four kinds of single-ended Ranges you list above, as well as the four kinds of double-ended Ranges and the "everything" range! |
Original comment posted by SeanPFloyd on 2010-12-17 at 08:33 AM nice, thanks for the info! |
Original comment posted by kevinb@google.com on 2011-01-27 at 06:17 AM (No comment entered for this change.) Status: |
Original issue created by SeanPFloyd on 2010-09-21 at 03:33 PM
I would like to see the following factory methods in Predicates:
Predicate<T> largerThan(T reference)
Predicate<T> largerThanOrEqual(T reference)
Predicate<T> smallerThan(T reference)
Predicate<T> smallerThanOrEqual(T reference)
where <T extends Comparable<T>> and all methods use compareTo() internally
sample usage:
Collections2.filter(Arrays.asList(1,2,3,4), Predicates.largerThan(2))
=> [3, 4]
Patch with sample code is attached.
The text was updated successfully, but these errors were encountered: