Provides some useful (especially for method references) functional methods for Java 8
import static run.smt.f.functional.Pipes.*;
import static run.smt.f.functional.signaturemanip.ArgumentManipulation.*;
import static run.smt.f.functional.signaturemanip.ReturnManipulation.*;
import static run.smt.f.predef.LogicChecks.*;
import static run.smt.f.predef.LogicOperator.*;
class Example {
public void usage() {
getSomeStream()
.filter(and(this::isUseful, this::isGood))
.filter(not(this::isWrong))
.filter(isNotNull())
.map(pipe(bind(this::convertToPojo, getArg()), Pojo::getField))
.foreach(expand(this::dontNeedArgs));
}
private Stream getSomeStream() {}
private boolean isUseful(Object elem) {}
private boolean isGood(Object elem) {}
private boolean isWrong(Object elem) {}
private Arg getArg() {}
private Pojo convertToPojoWithArg(Arg arg, Object elem) {}
private void dontNeedArgs() {}
}
definition
- Definition of functional interfacesfunctional
- Wrapper for easier usage with method references, contains all methods of functional interfaces as static methodspredicate
- Definition of predicates, extended methods in functional interfaces for easier usage with functions returning boolean valuespredef
- Predefined operations and checks for both simple functional interfaces fromdefinition
andpredicate
all
- Parent module for all listed above
<dependency>
<groupId>run.smt.f</groupId>
<artifactId>definition</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>run.smt.f</groupId>
<artifactId>functional</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>run.smt.f</groupId>
<artifactId>predicate</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>run.smt.f</groupId>
<artifactId>predef</artifactId>
<version>1.1.0</version>
</dependency>