Hi Adam,
Michael Neale (the drools guvnor guy) is also using Scala and Drools
Planner together. His code is at github.
He doesn't use such a hack (maybe he's still at drools 5.0.1 where it
was a double instead of Score). Why doesn't he?
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> >> ?
4) Or maybe it should be, just like EnumSet?
class Solution<S extends Score> {
public S getScore()
}
I don't like to fiddle trial&error with generics just "so it gives less
compiler issues". Only when the other alternatives are proven worse
(especially by referring to JDK class examples/conventions) and if it
makes sense, I 'll be happy to apply a fix and adjust the examples and
UpgradeRecipe. Better yet: a patch to do that is welcome too (if the
discussion proves it to be the best option).
With kind regards,
Geoffrey De Smet
Adam Warski schreef:
> Hello,
>
> I'm using Planner in a Scala program and it almost works without problems;
> the only one is in implementing the Solution interface, as it uses raw
> (erased) version of Score, which is normally generic (Score<S extends
> Score>). Scala generally doesn't like raw types and in most cases it's
> impossible to extend/implement interfaces which use them. A work-around is to
> introduce an "adapter" in Java, which you can later extend in Scala:
>
> public abstract class ScalaSolution implements Solution {
> public Score getScore() { return getScoreScala(); }
> public abstract Score<?> getScoreScala();
>
> public void setScore(Score score) { setScoreScala(score); }
> public abstract void setScoreScala(Score<?> score);
> }
>
> and then in Scala:
>
> class Schedule(...) extends ScalaSolution {
> var score: Score[_] = _
>
> def setScoreScala(score: Score[_]) = { this.score = score }
> def getScoreScala = score
>
> ...
> }
>
> So the fix is to replace the raw Score type with Score<?>. Maybe it would be
> possible to apply that in the code? I tried it locally and it compiles
> without problems.
>
> And a side question: do you have any plans on implementing multithreading in
> planner? So that several moves could be explored concurrently? I saw there's
> an open Jira issue for some time, but it didn't have any timeframe
> information.
>
_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users