[rules-users] [planner] Drools planner & Scala => Solution.getScore():Score<?>

Adam Warski adam at warski.org
Sat Feb 6 08:28:45 EST 2010


Hello,

> Michael Neale (the drools guvnor guy) is also using Scala and Drools 
> Planner together. His code is at github.
I was looking for his account but a search for "Neale" only finds some comments in BMW's repos. You know what his username is?

> If the issue still makes sense, feel free to open an issue for the
>   org.drools.planner.core.solution.Solution#getScore():Score<?>
> discussion (and copy this part of the discussion).
> Why should it be Score<?> and not
> 2) Score<S extends Score>
> 3) or Score<<S extends Score<S extends Score> >> ?
Well in case 2) Scala would still complain about a missing type parameter for the inner Score. Same for 3, it could go on forever. So for recursive type parameters you need to stop at some point and put in a wildcard (? in java or _ in scala). Score<?> and Score have the same meaning in Java (they both mean any Score), the only difference is that one works, the other not in Scala ;). And for the use in the Solution interface I think it's write - the get/set method store any score, you don't know which one.

> 4) Or maybe it should be, just like EnumSet?
> class Solution<S extends Score> {
>    public S getScore()
> }
This would of course work also, but it's a much bigger refactoring. And it could have some viral consequences. Score<?> instead of Score is just a drop-in replacement :).

-- 
Adam Warski
http://www.warski.org
http://www.softwaremill.eu








More information about the rules-users mailing list