Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Interface Like Predicate but Without Argument [closed]

I'm looking for a preexisting functional interface like Predicate, but one whose test method takes no arguments.

like image 747
Greg Valvo Avatar asked Apr 14 '15 20:04

Greg Valvo


People also ask

What is a predicate interface in Java?

Java Predicate Interface. It is a functional interface which represents a predicate (boolean-valued function) of one argument. It is defined in the java.util.function package and contains test() a functional method.

What is the predicate interface without lambda?

Using the Predicate interface without lambda, that is, as we did with the pre-java 8 sample code has exactly the same limitation that we had previously : verbosity. As other interesting and more advanced advantage, the interface provides additional methods to the test () method to provide a way to create composed predicates.

What is the difference between default predicate<T> and negate() methods?

default Predicate<T> or (Predicate<? super T> other) – This is also a default method, returns a composed predicate that by performing short-circuiting logical OR of current predicate and another predicate. default Predicate<T> negate () – This also a default method, returns a predicate after performing logical negation (!) on the current predicate.

What is a predefined functional interface in Java?

Java 8 Predicate with Examples. A Functional Interface is an Interface which allows only one Abstract method within the Interface scope. There are some predefined functional interface in Java like Predicate, consumer, supplier etc. The return type of a Lambda function (introduced in JDK 1.8) is a also functional interface.


1 Answers

You're looking for BooleanSupplier.

https://docs.oracle.com/javase/8/docs/api/java/util/function/BooleanSupplier.html

like image 86
Paul Boddington Avatar answered Sep 21 '22 11:09

Paul Boddington