Interface Predicate<A>
-
- Type Parameters:
A
- The argument type
- All Superinterfaces:
Applicative<java.lang.Boolean,Fn1<A,?>>
,Cartesian<A,java.lang.Boolean,Fn1<?,?>>
,Cocartesian<A,java.lang.Boolean,Fn1<?,?>>
,Contravariant<A,Profunctor<?,java.lang.Boolean,Fn1<?,?>>>
,Fn1<A,java.lang.Boolean>
,Functor<java.lang.Boolean,Fn1<A,?>>
,Monad<java.lang.Boolean,Fn1<A,?>>
,MonadReader<A,java.lang.Boolean,Fn1<A,?>>
,MonadRec<java.lang.Boolean,Fn1<A,?>>
,MonadWriter<A,java.lang.Boolean,Fn1<A,?>>
,Profunctor<A,java.lang.Boolean,Fn1<?,?>>
- All Known Implementing Classes:
Empty
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface Predicate<A> extends Fn1<A,java.lang.Boolean>
A specializedFn1
that returns aBoolean
.
-
-
Method Summary
All Methods Static Methods Instance Methods Default Methods Modifier and Type Method Description default Predicate<A>
and(Predicate<? super A> other)
Left-to-right short-circuiting logical conjunction.default <Y,Z>
BiPredicate<Y,Z>compose(Fn2<? super Y,? super Z,? extends A> before)
Right-to-left composition between different arity functions.default <Z> Predicate<Z>
contraMap(Fn1<? super Z,? extends A> fn)
Contravariantly mapA <- B
.default <Z> Predicate<Z>
diMapL(Fn1<? super Z,? extends A> fn)
Contravariantly map over the argument to this function, producing a function that takes the new argument type, and produces the same result.default <C> Predicate<A>
discardR(Applicative<C,Fn1<A,?>> appB)
Sequence both thisApplicative
andappB
, discardingappB's
result and returning thisApplicative
.static <A> Predicate<A>
fromPredicate(java.util.function.Predicate<A> predicate)
Create aPredicate
from a javaPredicate
.default Predicate<A>
negate()
Logical negation.default Predicate<A>
or(Predicate<? super A> other)
Left-to-right short-circuiting logical disjunction.static <A> Predicate<A>
predicate(Fn1<? super A,? extends java.lang.Boolean> predicate)
Static factory method to create a predicate from anFn1
.default java.util.function.Predicate<A>
toPredicate()
Convert thisPredicate
to a javaPredicate
.default <Z> BiPredicate<Z,A>
widen()
Widen this function's argument list by prepending an ignored argument of any type to the front.
-
-
-
Method Detail
-
diMapL
default <Z> Predicate<Z> diMapL(Fn1<? super Z,? extends A> fn)
Contravariantly map over the argument to this function, producing a function that takes the new argument type, and produces the same result.- Specified by:
diMapL
in interfaceCartesian<A,java.lang.Boolean,Fn1<?,?>>
- Specified by:
diMapL
in interfaceCocartesian<A,java.lang.Boolean,Fn1<?,?>>
- Specified by:
diMapL
in interfaceFn1<A,java.lang.Boolean>
- Specified by:
diMapL
in interfaceProfunctor<A,java.lang.Boolean,Fn1<?,?>>
- Type Parameters:
Z
- the new argument type- Parameters:
fn
- the contravariant argument mapping function- Returns:
- an
Fn1
<Z, B>
-
contraMap
default <Z> Predicate<Z> contraMap(Fn1<? super Z,? extends A> fn)
Contravariantly mapA <- B
.- Specified by:
contraMap
in interfaceCartesian<A,java.lang.Boolean,Fn1<?,?>>
- Specified by:
contraMap
in interfaceCocartesian<A,java.lang.Boolean,Fn1<?,?>>
- Specified by:
contraMap
in interfaceContravariant<A,Profunctor<?,java.lang.Boolean,Fn1<?,?>>>
- Specified by:
contraMap
in interfaceFn1<A,java.lang.Boolean>
- Specified by:
contraMap
in interfaceProfunctor<A,java.lang.Boolean,Fn1<?,?>>
- Type Parameters:
Z
- the new parameter type- Parameters:
fn
- the mapping function- Returns:
- the mapped Contravariant functor instance
-
widen
default <Z> BiPredicate<Z,A> widen()
Widen this function's argument list by prepending an ignored argument of any type to the front.
-
discardR
default <C> Predicate<A> discardR(Applicative<C,Fn1<A,?>> appB)
Sequence both thisApplicative
andappB
, discardingappB's
result and returning thisApplicative
. This is generally useful for sequentially performing side-effects.- Specified by:
discardR
in interfaceApplicative<java.lang.Boolean,Fn1<A,?>>
- Specified by:
discardR
in interfaceFn1<A,java.lang.Boolean>
- Specified by:
discardR
in interfaceMonad<java.lang.Boolean,Fn1<A,?>>
- Specified by:
discardR
in interfaceMonadReader<A,java.lang.Boolean,Fn1<A,?>>
- Specified by:
discardR
in interfaceMonadRec<java.lang.Boolean,Fn1<A,?>>
- Specified by:
discardR
in interfaceMonadWriter<A,java.lang.Boolean,Fn1<A,?>>
- Type Parameters:
C
- the type of appB's parameter- Parameters:
appB
- the other Applicative- Returns:
- this Applicative
-
compose
default <Y,Z> BiPredicate<Y,Z> compose(Fn2<? super Y,? super Z,? extends A> before)
Right-to-left composition between different arity functions. Preserves highest arity in the return type.
-
and
default Predicate<A> and(Predicate<? super A> other)
Left-to-right short-circuiting logical conjunction.- Parameters:
other
- the predicate to test if this one succeeds- Returns:
- a predicate representing the conjunction of this predicate and other
-
or
default Predicate<A> or(Predicate<? super A> other)
Left-to-right short-circuiting logical disjunction.- Parameters:
other
- the predicate to test if this one fails- Returns:
- a predicate representing the disjunction of this predicate and other
-
toPredicate
default java.util.function.Predicate<A> toPredicate()
Convert thisPredicate
to a javaPredicate
.- Returns:
- the
Predicate
-
predicate
static <A> Predicate<A> predicate(Fn1<? super A,? extends java.lang.Boolean> predicate)
Static factory method to create a predicate from anFn1
.- Type Parameters:
A
- the input type- Parameters:
predicate
- theFn1
- Returns:
- the predicate
-
-