Stay organized with collections
Save and categorize content based on your preferences.
BiPredicate
@FunctionalInterface interface BiPredicate<T : Any!, U : Any!>
Represents a predicate (boolean-valued function) of two arguments. This is the two-arity specialization of Predicate
.
This is a functional interface whose functional method is test(java.lang.Object,java.lang.Object)
.
Summary
Public methods |
open BiPredicate<T, U>! |
Returns a composed predicate that represents a short-circuiting logical AND of this predicate and another.
|
open BiPredicate<T, U>! |
Returns a predicate that represents the logical negation of this predicate.
|
open BiPredicate<T, U>! |
Returns a composed predicate that represents a short-circuiting logical OR of this predicate and another.
|
abstract Boolean |
Evaluates this predicate on the given arguments.
|
Public methods
and
open fun and(other: BiPredicate<in T, in U>!): BiPredicate<T, U>!
Returns a composed predicate that represents a short-circuiting logical AND of this predicate and another. When evaluating the composed predicate, if this predicate is false
, then the other
predicate is not evaluated.
Any exceptions thrown during evaluation of either predicate are relayed to the caller; if evaluation of this predicate throws an exception, the other
predicate will not be evaluated.
Parameters |
other |
BiPredicate<in T, in U>!: a predicate that will be logically-ANDed with this predicate |
Return |
BiPredicate<T, U>! |
a composed predicate that represents the short-circuiting logical AND of this predicate and the other predicate |
Exceptions |
java.lang.NullPointerException |
if other is null |
negate
open fun negate(): BiPredicate<T, U>!
Returns a predicate that represents the logical negation of this predicate.
Return |
BiPredicate<T, U>! |
a predicate that represents the logical negation of this predicate |
or
open fun or(other: BiPredicate<in T, in U>!): BiPredicate<T, U>!
Returns a composed predicate that represents a short-circuiting logical OR of this predicate and another. When evaluating the composed predicate, if this predicate is true
, then the other
predicate is not evaluated.
Any exceptions thrown during evaluation of either predicate are relayed to the caller; if evaluation of this predicate throws an exception, the other
predicate will not be evaluated.
Parameters |
other |
BiPredicate<in T, in U>!: a predicate that will be logically-ORed with this predicate |
Return |
BiPredicate<T, U>! |
a composed predicate that represents the short-circuiting logical OR of this predicate and the other predicate |
Exceptions |
java.lang.NullPointerException |
if other is null |
test
abstract fun test(
t: T,
u: U
): Boolean
Evaluates this predicate on the given arguments.
Parameters |
t |
T: the first input argument |
u |
U: the second input argument |
Return |
Boolean |
true if the input arguments match the predicate, otherwise false |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# BiPredicate\n\nAdded in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nBiPredicate\n===========\n\n```\n@FunctionalInterface interface BiPredicate\u003cT : Any!, U : Any!\u003e\n```\n\n|-------------------------------------|\n| [java.util.function.BiPredicate](#) |\n\nRepresents a predicate (boolean-valued function) of two arguments. This is the two-arity specialization of [Predicate](/reference/kotlin/java/util/function/Predicate).\n\nThis is a [functional interface](/reference/kotlin/java/util/function/package-summary) whose functional method is [test(java.lang.Object,java.lang.Object)](#test(java.util.function.BiPredicate.T,%20java.util.function.BiPredicate.U)).\n\nSummary\n-------\n\n| Public methods ||\n|---------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open [BiPredicate](#)\\\u003cT, U\\\u003e! | [and](#and(java.util.function.BiPredicate))`(`other:` `[BiPredicate](#)\u003cin` `T,` `in` `U\u003e!`)` Returns a composed predicate that represents a short-circuiting logical AND of this predicate and another. |\n| open [BiPredicate](#)\\\u003cT, U\\\u003e! | [negate](#negate())`()` Returns a predicate that represents the logical negation of this predicate. |\n| open [BiPredicate](#)\\\u003cT, U\\\u003e! | [or](#or(java.util.function.BiPredicate))`(`other:` `[BiPredicate](#)\u003cin` `T,` `in` `U\u003e!`)` Returns a composed predicate that represents a short-circuiting logical OR of this predicate and another. |\n| abstract [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [test](#test(java.util.function.BiPredicate.T,%20java.util.function.BiPredicate.U))`(`t:` `T`, `u:` `U`)` Evaluates this predicate on the given arguments. |\n\nPublic methods\n--------------\n\n### and\n\nAdded in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun and(other: BiPredicate\u003cin T, in U\u003e!): BiPredicate\u003cT, U\u003e!\n```\n\nReturns a composed predicate that represents a short-circuiting logical AND of this predicate and another. When evaluating the composed predicate, if this predicate is `false`, then the `other` predicate is not evaluated.\n\nAny exceptions thrown during evaluation of either predicate are relayed to the caller; if evaluation of this predicate throws an exception, the `other` predicate will not be evaluated.\n\n| Parameters ||\n|---------|-----------------------------------------------------------------------------------------------|\n| `other` | [BiPredicate](#)\\\u003cin T, in U\\\u003e!: a predicate that will be logically-ANDed with this predicate |\n\n| Return ||\n|---------------------------|-------------------------------------------------------------------------------------------------------------------|\n| [BiPredicate](#)\u003cT,` `U\u003e! | a composed predicate that represents the short-circuiting logical AND of this predicate and the `other` predicate |\n\n| Exceptions ||\n|----------------------------------|------------------|\n| `java.lang.NullPointerException` | if other is null |\n\n### negate\n\nAdded in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun negate(): BiPredicate\u003cT, U\u003e!\n```\n\nReturns a predicate that represents the logical negation of this predicate.\n\n| Return ||\n|---------------------------|--------------------------------------------------------------------|\n| [BiPredicate](#)\u003cT,` `U\u003e! | a predicate that represents the logical negation of this predicate |\n\n### or\n\nAdded in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun or(other: BiPredicate\u003cin T, in U\u003e!): BiPredicate\u003cT, U\u003e!\n```\n\nReturns a composed predicate that represents a short-circuiting logical OR of this predicate and another. When evaluating the composed predicate, if this predicate is `true`, then the `other` predicate is not evaluated.\n\nAny exceptions thrown during evaluation of either predicate are relayed to the caller; if evaluation of this predicate throws an exception, the `other` predicate will not be evaluated.\n\n| Parameters ||\n|---------|----------------------------------------------------------------------------------------------|\n| `other` | [BiPredicate](#)\\\u003cin T, in U\\\u003e!: a predicate that will be logically-ORed with this predicate |\n\n| Return ||\n|---------------------------|------------------------------------------------------------------------------------------------------------------|\n| [BiPredicate](#)\u003cT,` `U\u003e! | a composed predicate that represents the short-circuiting logical OR of this predicate and the `other` predicate |\n\n| Exceptions ||\n|----------------------------------|------------------|\n| `java.lang.NullPointerException` | if other is null |\n\n### test\n\nAdded in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun test(\n t: T, \n u: U\n): Boolean\n```\n\nEvaluates this predicate on the given arguments.\n\n| Parameters ||\n|-----|------------------------------|\n| `t` | T: the first input argument |\n| `u` | U: the second input argument |\n\n| Return ||\n|------------------------------------------------------------------------------------|----------------------------------------------------------------------|\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `true` if the input arguments match the predicate, otherwise `false` |"]]