I just released version 1.3.0 of Funcito, the OSS API that works with Jedi (and several other libraries with functional idiom APIs), to wrap method calls as
functional-objects. It is at:
https://code.google.com/p/funcito/
or for Maven Central:
http://search.maven.org/#artifactdetails|com.googlecode.funcito|funcito|1.3.0|jar
As a summary, Funcito helps eliminate some of the "vertical problem" inherent in creating
Functions/Predicates as inner classes, instead
using proxying technologies to wrap existing methods as
functional-objects in concise, expressive and refactor-safe code,
usually in a
single clear line.
There are two primary features in this release that would be of interest to Jedi users: support for the Command object, and custom execution modes (especially
SafeNav).
The first of these features is added support for Jedi
Command. See the
website documentation for how to use factory methods to create your Jedi Command objects easily.
The second prominent feature would be the addition of the
SafeNav mode,
and the addition of execution modes in general. All functional object
factory methods have been overloaded to take an optional
Mode or
TypedMode that controls the execution. The highlighted provided Mode,
SafeNav, behaves very similarly to the Groovy safe-navigation operator,
"?.",
providing a short-hand null check for every segment in a method call
chain, with a default return value of null if any segment evaluates to
null. In addition, you can explicitly provide a default value other
than null.
As an example, instead of having to code for potential nulls as follows:
Functor<A,D> func = new Functor<A,D> {
@Override
public D execute(A a) {
if (a!=null && a.b()!=null && a.b().c()!=null) {
return a.b().c().d();
}
}
}
You could instead do:
Function<A,D> func = functorFor(callsTo(A.class), safeNav()).b().c().d()));The complete list of 1.3.0 changes follows:
- Support for Netflix RxJava framework, including both Func1 and Action1 types
- "Command"-like functor support in Jedi, Functional Java, Collection-generic, Play!, and RxJava
- Modes and TypedModes, including SafeNav (like the Groovy operator), TailDefault and others
- Users can define and use their own custom modes
- Mode and TypedMode versions of all factory methods
- Alternative static access to set ProxyFactory (proxy provider)
- ProxyFactory log message downgraded from warning to info
- Upgraded Javadoc format (Java 7 generator)
- upgrade of Gradle build to 1.6
- improved tests and improved test coverage
- upgraded Objenesis from 1.2 to 2.1
If are interested in contributing to the direction, features, or quality of Funcito,
please contribute
Issues on the project web site, or join the project
Google group at:
https://groups.google.com/group/funcito