If a mod object is present, and the mod object matches the given predicate, return an OptionalMod describing the value, otherwise return an empty OptionalMod. @param predicate a predicate to apply to the mod object, if present @return an OptionalMod describing the value of t
(Predicate<? super T> predicate)
| 117 | * @throws NullPointerException if the predicate is null |
| 118 | */ |
| 119 | public OptionalMod<T> filter(Predicate<? super T> predicate) { |
| 120 | Objects.requireNonNull(predicate); |
| 121 | if (!isPresent()) |
| 122 | return this; |
| 123 | else |
| 124 | return predicate.test(getValue()) ? this : empty(); |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * If a mod object is present, apply the provided mapping function to it, |
no test coverage detected