computerluca / lambdaj

Automatically exported from code.google.com/p/lambdaj
1 stars 0 forks source link

Cannot use Iterable<Double> because Double is a final class #11

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use this code:

//just create any abitrary list of jdk final types:
List<Double> numbers = com.google.common.collect.Lists.newArrayList(1.0, 2.0);

Double minimum = minFrom(numbers);

What is the expected output? What do you see instead?
minimum = 1.0.
I get an exception "Double is a final class and cannot be proxied".

Before version 1.10, we had some code inside to proxy a final class.
However it has been removed by Mario during the merge with my changes to
proxy classes without relying on a default constructor. 

What was the reason to remove it?

-Sebastian

Original issue reported on code.google.com by sebastian.jancke@googlemail.com on 13 Jul 2009 at 3:04

GoogleCodeExporter commented 9 years ago
You are just misusing the lambdaj API. minFrom() is intended to create a proxy 
of a
list of object in order to find the minimum value on a give property of those 
objects
like in the following example:

Integer age = minFrom(persons).getAge();

To achieve the result you wanted you should use the min() method instad, as it 
follows:

Double minimum = min(numbers);

I hope this helps
Mario

Original comment by mario.fu...@gmail.com on 13 Jul 2009 at 3:16

GoogleCodeExporter commented 9 years ago
Mario,

you are right. I haven't been aware of min(...).

-Sebastian

Original comment by sebastian.jancke@googlemail.com on 14 Jul 2009 at 7:14