As I have started to invest in using functional idioms in Java, I
discovered that oftentimes the creation of function-type objects like
a fj.F often add as much noise and complexity to the source code as
they reduce when they are used to replace for-loops. This bothered
me, since often the function I am trying to create is simply a wrapper
around a simple method that already exists. So I have created a
library, Funcito, to simplify function creation in existing functional
libraries such as FJ. It is found at:
http://funcito.googlecode.com
As an example take the following code before Funcito:
F<String, Integer> lengthFunction = new F<String, Integer>() {
public Integer f(String string) {
return string.length();
}
};
With Funcito this gets replaced by:
F<String, Integer> lengthFunction =
fFor( callsTo(CharSequnce.class).length() );
If you have more than one method you want to wrap on the same
interface or class, notation can be expressed even more concise and
readable:
CharSequence callsTo = callsTo(CharSequence.class);
F<CharSequence, Integer> length = fFor( callsTo.length() );
F<CharSequence, String> toString = fFor( callsTo.toString() );