From 8d5bb66d66daccf1e5f2361271fa8fa1fc2d8b59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Petrovick=C3=BD?= Date: Mon, 7 Oct 2024 13:01:43 +0200 Subject: [PATCH] Final fix --- .../impl/solver/DefaultRecommendedFit.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 core/src/main/java/ai/timefold/solver/core/impl/solver/DefaultRecommendedFit.java diff --git a/core/src/main/java/ai/timefold/solver/core/impl/solver/DefaultRecommendedFit.java b/core/src/main/java/ai/timefold/solver/core/impl/solver/DefaultRecommendedFit.java new file mode 100644 index 0000000000..d7724939d7 --- /dev/null +++ b/core/src/main/java/ai/timefold/solver/core/impl/solver/DefaultRecommendedFit.java @@ -0,0 +1,27 @@ +package ai.timefold.solver.core.impl.solver; + +import ai.timefold.solver.core.api.score.Score; +import ai.timefold.solver.core.api.score.analysis.ScoreAnalysis; +import ai.timefold.solver.core.api.solver.RecommendedFit; + +/** + * @deprecated Prefer {@link DefaultRecommendedAssignment} instead. + */ +@Deprecated(forRemoval = true, since = "1.15.0") +public record DefaultRecommendedFit>(long index, Proposition_ proposition, + ScoreAnalysis scoreAnalysisDiff) + implements + RecommendedFit, + Comparable> { + + @Override + public int compareTo(DefaultRecommendedFit other) { + int scoreComparison = scoreAnalysisDiff.score().compareTo(other.scoreAnalysisDiff.score()); + if (scoreComparison != 0) { + return -scoreComparison; // Better scores first. + } + // Otherwise maintain insertion order. + return Long.compareUnsigned(index, other.index); // Unsigned == many more positive values. + } + +}