P1
- parameter type 1P2
- parameter type 2P3
- parameter type 3@FunctionalInterface public interface Predicate3<P1,P2,P3> extends Predicate1<ITuple3<? extends P1,? extends P2,? extends P3>>
Predicates can be chained to simulate boolean logic by
and(Predicate3)
, or(Predicate3)
,
xor(Predicate3)
, and negate()
.
There is a general problem with combining types which don't
allow to use the above combination methods in all cases
similar to standard Java's logical expressions. The following
static methods of this interface may be used in all cases:
and(Predicate3, Predicate3)
,
or(Predicate3, Predicate3)
,
and xor(Predicate3, Predicate3)
.
Useful for start values in algorithms or as default values
are the two values returned by alwaysTrue()
(a predicate which always returns true
regardless
the argument applied to the test(Object, Object, Object)
method)
and alwaysFalse()
(same for false
).
Partial evaluation is possible via partialLeft(Object)
which allows to provide a fix first argument,
partialMid(Object)
which provides a fix second argument,
and partialRight(Object)
which provides a fix third argument.
All three return a Predicate2
with the types of the other two
arguments.
The five methods order132()
, order213()
,
order231()
, order312()
, and order321()
convert a predicate to one which expects a different order of arguments.
Predicate1
,
Predicate2
,
Predicate4
,
Predicate5
,
Predicate6
,
Predicate7
,
Predicate8
,
Predicate9
ALWAYS_FALSE, ALWAYS_TRUE
Modifier and Type | Method and Description |
---|---|
default <FR extends ITuple3<? extends P1,? extends P2,? extends P3>,FP> |
after1(java.util.function.Function<FP,FR> before)
Get a chained predicate which first applies the given function, then this predicate.
|
default <FR extends ITuple3<? extends P1,? extends P2,? extends P3>,FP1,FP2> |
after2(java.util.function.BiFunction<FP1,FP2,FR> before)
Get a chained predicate which first applies the given 2-parameter function, then this predicate.
|
default <FR extends ITuple3<? extends P1,? extends P2,? extends P3>,FP1,FP2,FP3> |
after3(Function3<FR,FP1,FP2,FP3> before)
Get a chained predicate which first applies the given 3-parameter function, then this predicate.
|
default <FR extends ITuple3<? extends P1,? extends P2,? extends P3>,FP1,FP2,FP3,FP4,FP5> |
after5(Function5<FR,FP1,FP2,FP3,FP4,FP5> before)
Get a chained predicate which first applies the given 5-parameter function, then this predicate.
|
default <FR extends ITuple3<? extends P1,? extends P2,? extends P3>,FP1,FP2,FP3,FP4,FP5,FP6> |
after6(Function6<FR,FP1,FP2,FP3,FP4,FP5,FP6> before)
Get a chained predicate which first applies the given 6-parameter function, then this predicate.
|
default <FR extends ITuple3<? extends P1,? extends P2,? extends P3>,FP1,FP2,FP3,FP4,FP5,FP6,FP7> |
after7(Function7<FR,FP1,FP2,FP3,FP4,FP5,FP6,FP7> before)
Get a chained predicate which first applies the given 7-parameter function, then this one.
|
default <FR extends ITuple3<? extends P1,? extends P2,? extends P3>,FP1,FP2,FP3,FP4,FP5,FP6,FP7,FP8> |
after8(Function8<FR,FP1,FP2,FP3,FP4,FP5,FP6,FP7,FP8> before)
Get a chained predicate which first applies the given 8-parameter function, then this one.
|
default <FR extends ITuple3<? extends P1,? extends P2,? extends P3>,FP1,FP2,FP3,FP4,FP5,FP6,FP7,FP8,FP9> |
after9(Function9<FR,FP1,FP2,FP3,FP4,FP5,FP6,FP7,FP8,FP9> before)
Get a chained predicate which first applies the given 9-parameter function, then this one.
|
static <T1,T2,T3> Predicate3<T1,T2,T3> |
alwaysFalse()
Get a predicate which always evaluates to
false . |
static <T1,T2,T3> Predicate3<T1,T2,T3> |
alwaysTrue()
Get a predicate which always evaluates to
true . |
default Predicate3<P1,P2,P3> |
and(Predicate3<? super P1,? super P2,? super P3> other)
Combine this and another predicate with logical and.
|
static <T1,T2,T3> Predicate3<T1,T2,T3> |
and(Predicate3<? super T1,? super T2,? super T3> pred1,
Predicate3<? super T1,? super T2,? super T3> pred2)
Get a predicate which is the combination of two predicates
with a logical and.
|
default Predicate3<P1,P2,P3> |
negate()
Get the negation of this predicate.
|
default Predicate3<P1,P2,P3> |
or(Predicate3<? super P1,? super P2,? super P3> other)
Combine this and another predicate with logical or.
|
static <T1,T2,T3> Predicate3<T1,T2,T3> |
or(Predicate3<? super T1,? super T2,? super T3> pred1,
Predicate3<? super T1,? super T2,? super T3> pred2)
Get a predicate which is the combination of two predicates
with a logical or.
|
default Predicate3<P1,P3,P2> |
order132()
Get a three argument predicate which expects the arguments in different order.
|
default Predicate3<P2,P1,P3> |
order213()
Get a three argument predicate which expects the arguments in different order.
|
default Predicate3<P2,P3,P1> |
order231()
Get a three argument predicate which expects the arguments in different order.
|
default Predicate3<P3,P1,P2> |
order312()
Get a three argument predicate which expects the arguments in different order.
|
default Predicate3<P3,P2,P1> |
order321()
Get a three argument predicate which expects the arguments in different order.
|
default Predicate2<P2,P3> |
partial1(P1 argument)
Get a partially applied predicate with a fix first argument.
|
default Predicate2<P1,P3> |
partial2(P2 argument)
Get a partially applied predicate with a fix second argument.
|
default Predicate2<P1,P2> |
partial3(P3 argument)
Get a partially applied predicate with a fix third argument.
|
default Predicate2<P2,P3> |
partialLeft(P1 argument)
Get a partially applied predicate.
|
default Predicate2<P1,P3> |
partialMid(P2 argument)
Get a partially applied predicate.
|
default Predicate2<P1,P2> |
partialRight(P3 argument)
Get a partially applied predicate.
|
default boolean |
test(ITuple3<? extends P1,? extends P2,? extends P3> tuple3)
Expand a tuple into the arguments of this predicate.
|
boolean |
test(P1 arg1,
P2 arg2,
P3 arg3)
Test the given values.
|
default Predicate3<P1,P2,P3> |
xor(Predicate3<? super P1,? super P2,? super P3> other)
Combine this and another predicate with logical exclusive or.
|
static <T1,T2,T3> Predicate3<T1,T2,T3> |
xor(Predicate3<? super T1,? super T2,? super T3> pred1,
Predicate3<? super T1,? super T2,? super T3> pred2)
Get a predicate which is the combination of two predicates
with a logical exclusive or.
|
boolean test(P1 arg1, P2 arg2, P3 arg3)
arg1
- function argument 1arg2
- function argument 2arg3
- function argument 3true
or false
default boolean test(@NotNull ITuple3<? extends P1,? extends P2,? extends P3> tuple3)
@NotNull default Predicate3<P1,P2,P3> and(@NotNull Predicate3<? super P1,? super P2,? super P3> other)
false
the other one is
not evaluated.
This method has a problem if either one of the argument types
pf the parameter is not a super class of this predicate's
parameter types. See and(Predicate3, Predicate3)
for such cases.
other
- other predicate to be chained with logical and@NotNull default Predicate3<P1,P2,P3> or(@NotNull Predicate3<? super P1,? super P2,? super P3> other)
true
the other one is
not evaluated.
This method has a problem if either one of the argument types
pf the parameter is not a super class of this predicate's
parameter types. See or(Predicate3, Predicate3)
for such cases.
other
- other predicate to be chained with logical or@NotNull default Predicate3<P1,P2,P3> xor(@NotNull Predicate3<? super P1,? super P2,? super P3> other)
This method has a problem if either one of the argument types
pf the parameter is not a super class of this predicate's
parameter types. See xor(Predicate3, Predicate3)
for such cases.
other
- other predicate to be chained with logical exclusive or@NotNull default Predicate3<P1,P2,P3> negate()
@NotNull default Predicate2<P2,P3> partialLeft(P1 argument)
argument
- value applied for first argument@NotNull default Predicate2<P2,P3> partial1(P1 argument)
partialLeft(Object)
but more consitently named.argument
- value applied for first argument@NotNull default Predicate2<P1,P3> partialMid(P2 argument)
argument
- value applied for second argument@NotNull default Predicate2<P1,P3> partial2(P2 argument)
partialMid(Object)
but more consistently named.argument
- value applied for second argument@NotNull default Predicate2<P1,P2> partialRight(P3 argument)
argument
- value applied for third argument@NotNull default Predicate2<P1,P2> partial3(P3 argument)
partialRight(Object)
but more consistently named.argument
- value applied for third argument@NotNull default Predicate3<P2,P3,P1> order231()
@NotNull default Predicate3<P3,P1,P2> order312()
@NotNull default Predicate3<P3,P2,P1> order321()
@NotNull default Predicate3<P1,P3,P2> order132()
@NotNull default Predicate3<P2,P1,P3> order213()
@NotNull static <T1,T2,T3> Predicate3<T1,T2,T3> alwaysTrue()
true
.alwaysTrue
in interface Predicate1<ITuple3<? extends P1,? extends P2,? extends P3>>
T1
- type of first predicate parameterT2
- type of second predicate parameterT3
- type of third predicate parametertrue
@NotNull static <T1,T2,T3> Predicate3<T1,T2,T3> alwaysFalse()
false
.alwaysFalse
in interface Predicate1<ITuple3<? extends P1,? extends P2,? extends P3>>
T1
- type of first predicate parameterT2
- type of second predicate parameterT3
- type of third predicate parameterfalse
@NotNull static <T1,T2,T3> Predicate3<T1,T2,T3> and(@NotNull Predicate3<? super T1,? super T2,? super T3> pred1, @NotNull Predicate3<? super T1,? super T2,? super T3> pred2)
The result will use shortcut evaluation, so if this
predicate already returns false
the other one is
not evaluated.
T1
- resulting type of first argument,
which is the most extending type of both pred1
's
first argument type and pred2
's first argument type,
so if neither type is extending the
other this method will not compileT2
- resulting type of second argument, see <T1>
for the fine printT3
- resulting type of third argument, see <T1>
for the fine printpred1
- first predicatepred2
- second predicateand(Predicate3)
@NotNull static <T1,T2,T3> Predicate3<T1,T2,T3> or(@NotNull Predicate3<? super T1,? super T2,? super T3> pred1, @NotNull Predicate3<? super T1,? super T2,? super T3> pred2)
The result will use shortcut evaluation, so if this
predicate already returns true
the other one is
not evaluated.
T1
- resulting type of first argument,
which is the most extending type of both pred1
's
first argument type and pred2
's first argument type,
so if neither type is extending the
other this method will not compileT2
- resulting type of second argument, see <T1>
for the fine printT3
- resulting type of third argument, see <T1>
for the fine printpred1
- first predicatepred2
- second predicateor(Predicate3)
@NotNull static <T1,T2,T3> Predicate3<T1,T2,T3> xor(@NotNull Predicate3<? super T1,? super T2,? super T3> pred1, @NotNull Predicate3<? super T1,? super T2,? super T3> pred2)
The result will use shortcut evaluation, so if this
predicate already returns true
the other one is
not evaluated.
T1
- resulting type of first argument,
which is the most extending type of both pred1
's
first argument type and pred2
's first argument type,
so if neither type is extending the
other this method will not compileT2
- resulting type of second argument, see <T1>
for the fine printT3
- resulting type of third argument, see <T1>
for the fine printpred1
- first predicatepred2
- second predicatexor(Predicate3)
@NotNull default <FR extends ITuple3<? extends P1,? extends P2,? extends P3>,FP> Predicate1<FP> after1(@NotNull java.util.function.Function<FP,FR> before)
ITuple3
with matching parametric types
which are applied in their order to this predicate.FR
- function before
's return type, has to be a 3-tuple with matching typesFP
- function before
's parameter type, same for returned predicatebefore
- function to apply first, has to return a non-null
result so unpacking the parameters
from the tuple is possible@NotNull default <FR extends ITuple3<? extends P1,? extends P2,? extends P3>,FP1,FP2> Predicate2<FP1,FP2> after2(@NotNull java.util.function.BiFunction<FP1,FP2,FR> before)
ITuple3
with matching parametric types
which are applied in their order to this predicate.FR
- function before
's return type, has to be a 3-tuple with matching typesFP1
- function before
's first parameter type, sane for returned predicateFP2
- function before
's second parameter type, same for returned predicatebefore
- function to apply first, has to return a non-null
result so unpacking the parameters
from the tuple is possible@NotNull default <FR extends ITuple3<? extends P1,? extends P2,? extends P3>,FP1,FP2,FP3> Predicate3<FP1,FP2,FP3> after3(@NotNull Function3<FR,FP1,FP2,FP3> before)
ITuple3
with matching parametric types
which are applied in their order to this predicate.FR
- function before
's return type, has to be a 3-tuple with matching typesFP1
- function before
's first parameter type, sane for returned predicateFP2
- function before
's second parameter type, sane for returned predicateFP3
- function before
's third parameter type, sane for returned predicatebefore
- function to apply first, has to return a non-null
result so unpacking the parameters
from the tuple is possible@NotNull default <FR extends ITuple3<? extends P1,? extends P2,? extends P3>,FP1,FP2,FP3,FP4,FP5> Predicate5<FP1,FP2,FP3,FP4,FP5> after5(@NotNull Function5<FR,FP1,FP2,FP3,FP4,FP5> before)
ITuple3
with matching parametric types
which are applied in their order to this function.FR
- function before
's return type, has to be a 3-tuple with matching typesFP1
- function before
's first parameter type, sane for returned predicateFP2
- function before
's second parameter type, sane for returned predicateFP3
- function before
's third parameter type, sane for returned predicateFP4
- function before
's fourth parameter type, sane for returned predicateFP5
- function before
's fifth parameter type, sane for returned predicatebefore
- function to apply first, has to return a non-null
result so unpacking the parameters
from the tuple is possible@NotNull default <FR extends ITuple3<? extends P1,? extends P2,? extends P3>,FP1,FP2,FP3,FP4,FP5,FP6> Predicate6<FP1,FP2,FP3,FP4,FP5,FP6> after6(@NotNull Function6<FR,FP1,FP2,FP3,FP4,FP5,FP6> before)
ITuple3
with matching parametric types
which are applied in their order to this function.FR
- function before
's return type, has to be a 3-tuple with matching typesFP1
- function before
's first parameter type, sane for returned predicateFP2
- function before
's second parameter type, sane for returned predicateFP3
- function before
's third parameter type, sane for returned predicateFP4
- function before
's fourth parameter type, sane for returned predicateFP5
- function before
's fifth parameter type, sane for returned predicateFP6
- function before
's sixth parameter type, sane for returned predicatebefore
- function to apply first, has to return a non-null
result so unpacking the parameters
from the tuple is possible@NotNull default <FR extends ITuple3<? extends P1,? extends P2,? extends P3>,FP1,FP2,FP3,FP4,FP5,FP6,FP7> Predicate7<FP1,FP2,FP3,FP4,FP5,FP6,FP7> after7(@NotNull Function7<FR,FP1,FP2,FP3,FP4,FP5,FP6,FP7> before)
ITuple3
with matching parametric types
which are applied in their order to this predicate.FR
- function before
's return type, has to be a 3-tuple with matching typesFP1
- function before
's first parameter type, sane for returned predicateFP2
- function before
's second parameter type, sane for returned predicateFP3
- function before
's third parameter type, sane for returned predicateFP4
- function before
's fourth parameter type, sane for returned predicateFP5
- function before
's fifth parameter type, sane for returned predicateFP6
- function before
's sixth parameter type, sane for returned predicateFP7
- function before
's seventh parameter type, sane for returned predicatebefore
- function to apply first, has to return a non-null
result so unpacking the parameters
from the tuple is possible@NotNull default <FR extends ITuple3<? extends P1,? extends P2,? extends P3>,FP1,FP2,FP3,FP4,FP5,FP6,FP7,FP8> Predicate8<FP1,FP2,FP3,FP4,FP5,FP6,FP7,FP8> after8(@NotNull Function8<FR,FP1,FP2,FP3,FP4,FP5,FP6,FP7,FP8> before)
ITuple3
with matching parametric types
which are applied in their order to this predicate.FR
- function before
's return type, has to be a 3-tuple with matching typesFP1
- function before
's first parameter type, sane for returned predicateFP2
- function before
's second parameter type, sane for returned predicateFP3
- function before
's third parameter type, sane for returned predicateFP4
- function before
's fourth parameter type, sane for returned predicateFP5
- function before
's fifth parameter type, sane for returned predicateFP6
- function before
's sixth parameter type, sane for returned predicateFP7
- function before
's seventh parameter type, sane for returned predicateFP8
- function before
's seventh parameter type, sane for returned predicatebefore
- function to apply first, has to return a non-null
result so unpacking the parameters
from the tuple is possible@NotNull default <FR extends ITuple3<? extends P1,? extends P2,? extends P3>,FP1,FP2,FP3,FP4,FP5,FP6,FP7,FP8,FP9> Predicate9<FP1,FP2,FP3,FP4,FP5,FP6,FP7,FP8,FP9> after9(@NotNull Function9<FR,FP1,FP2,FP3,FP4,FP5,FP6,FP7,FP8,FP9> before)
ITuple3
with matching parametric types
which are applied in their order to this predicate.FR
- function before
's return type, has to be a 3-tuple with matching typesFP1
- function before
's first parameter type, sane for returned predicateFP2
- function before
's second parameter type, sane for returned predicateFP3
- function before
's third parameter type, sane for returned predicateFP4
- function before
's fourth parameter type, sane for returned predicateFP5
- function before
's fifth parameter type, sane for returned predicateFP6
- function before
's sixth parameter type, sane for returned predicateFP7
- function before
's seventh parameter type, sane for returned predicateFP8
- function before
's seventh parameter type, sane for returned predicateFP9
- function before
's ninth parameter type, sane for returned predicatebefore
- function to apply first, has to return a non-null
result so unpacking the parameters
from the tuple is possible