commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bruno P. Kinoshita" <brunodepau...@yahoo.com.br>
Subject [functor] Using [fucntor] functional interfaces with Java 8 lambdas
Date Fri, 21 Dec 2012 19:22:35 GMT
Hi all, 

Just wanted to let you guys know that I am successfully compiling and executing code using [functor] and
Java 8. And am also using [functor] functional interfaces with lambdas.

So instead of writing:


UnaryPredicate isEven = new UnaryPredicate() {
    public boolean test(Integer obj) {
        return obj % 2 == 0;
    }
};

One can simply write:

UnaryPredicate isEven = (Integer obj) -> { return obj % 2 == 0; };

FWIW, Google Guava's Predicate [1] is not a functional interface, so it cannot be used with
lambdas, as in the example above.

I'll continue to experiment with [functor] and Java 8. There are only two open issues in Jira,
one regarding generators (there's a branch with a proposal implementation) and another one
about the equals() method in the [functor] API. 

I wrote a short blog post [2] about how I'm running Java 8 in Eclipse Juno, in case anyone
is interested in trying it too. The code is hosted at GitHub [3].

Cheers, 

[1] http://code.google.com/p/guava-libraries/source/browse/guava/src/com/google/common/base/Predicate.java
[2] http://www.kinoshita.eti.br/2012/12/21/using-apache-commons-functor-functional-interfaces-with-java-8-lambdas/
[3] https://github.com/kinow/try-lambdas
Bruno P. Kinoshita
http://kinoshita.eti.br
http://tupilabs.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message