Skip to content

Commit e86e212

Browse files
committed
Adding predicate static factory method
1 parent fc83731 commit e86e212

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
99
- ***Breaking Change***: `Absent` moved to `semigroup.builtin` package
1010
- `RightAny` overload returns `Monoid`
1111

12+
### Added
13+
- `Predicate#predicate` static factory method
14+
1215
## [3.1.0] - 2018-07-16
1316
### Added
1417
- `Fn3-8` static factory overloads to aid in coercing lambdas

src/main/java/com/jnape/palatable/lambda/functions/specialized/Predicate.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,15 @@ default Predicate<A> or(java.util.function.Predicate<? super A> other) {
8282
default Predicate<A> negate() {
8383
return a -> !apply(a);
8484
}
85+
86+
/**
87+
* Static factory method to create a predicate from a function.
88+
*
89+
* @param predicate the function
90+
* @param <A> the input type
91+
* @return the predicate
92+
*/
93+
static <A> Predicate<A> predicate(Function<? super A, Boolean> predicate) {
94+
return predicate::apply;
95+
}
8596
}

0 commit comments

Comments
 (0)