Best Java Functor lib: JGA, commons functor, mango, or ...?

I am interested in using functors (function objects) in Java. With a quick google search, I found these 3 packages:

and 3, JGA thought it might have a better design. But I suspect that other people who actually used one or more packages could offer more information about the pros and cons of these (and possibly other) feature packages.

+7
java functor
source share
4 answers

The Google Collection Library provides a Function interface that is similar (although probably not as detailed).

+3
source share

Mango

Provides interfaces for argument functions 0, 1, and 2. Uses Java generics. A good range of algorithms for working with functions.

Jga

Provides classes for 0, 1, 2 and an arbitrary number of argument functions. Subclass of subclass objects. Uses Java generics. A wide range of algorithms. Includes JFXG (Java Functor eXpression Grammar) - a parsed language designed to simplify the creation of arbitrarily complex functors. Provides several algorithms for working with functions.

Apocal commons functor

Provides interfaces for argument functions 0, 1, and 2, as well as argument procedures 0, 1, and 2 (which do not return a value). Uses Java generics. Good range of algorithms.

Google Guava (were Google collections)

Provides function and predicate interfaces for single argument functions. Uses Java generics. Provides only a layout method for combining functions. Pretty simple.

FunctionalJ

Provides interfaces and classes for 0, 1, 2 and an arbitrary number of argument functions. Uses Java generics. Existing methods can be turned into functions through function mapping classes.

+8
source share

I hope I don’t hurt anyone by saying that the function object is not a functor. Look at the functor on Wikipedia. And please stop abusing this term.

+4
source share

swensen.functional, http://www.codeproject.com/KB/java/FunctionalJava.aspx , in its own way.

Provides common interfaces for a single method, encapsulating from 0 to 5 argument functions (FuncX) and procedures (ActionX). It also includes the Predicate functor (an abstract class that implements Func2 <T, Boolean>) and three others designed to be compatible with legacy Comparator, Runnable, and Callable functors. And to make it all useful, the immutable Iterable type (constructed from all arrays and iterations) containing a chain of methods, lazy evaluation and functional predictions such as a filter, map, and bend.

Pro: Simple but effective, without a hierarchy of hierarchical types that undermine the spirit of fp.
Con: New and not yet experienced battles.

+2
source share

All Articles