Functional interface confusion

Stephen Colebourne scolebourne at
Sun Jul 7 12:12:42 PDT 2013

On 7 July 2013 12:25, Remi Forax <forax at> wrote:
> Casting is never the right incantation when you have trouble with
> generics :)

No, the right incantation is almost always to remove the generics.

You might think that is a quip, but in pretty much every recent case
I've faced where generics are causing problems, the best option is
removing the generics altogether. It results in much nicer, clearer
code that is better for users, even if they have to manually add the
occasional cast. My experience of generics is really pretty negative.
So, this case is not much different for me - its just another
"generics don't work here" case.

>   The syntax should be something like this:
>     (<T extends Temporal> T temporal) -> temporal.with(DAY_OF_MONTH, 1);

> In your case, if someone want to write a non ISO calendar, asking him/her
> to use method references doesn't seem to be a big deal for me.

TemporalAdjuster is used by all calendar systems, including ISO. The
cast that results from not having generics is generally in pre-written
libraries, so not having generics is not a huge loss.


More information about the lambda-dev mailing list