diff --git a/core/src/main/java/ai/timefold/solver/core/api/score/analysis/ConstraintAnalysis.java b/core/src/main/java/ai/timefold/solver/core/api/score/analysis/ConstraintAnalysis.java index 9a717545bf..00174270ab 100644 --- a/core/src/main/java/ai/timefold/solver/core/api/score/analysis/ConstraintAnalysis.java +++ b/core/src/main/java/ai/timefold/solver/core/api/score/analysis/ConstraintAnalysis.java @@ -61,6 +61,7 @@ public ConstraintAnalysis(@NonNull ConstraintRef constraintRef, @NonNull Score_ } } + @NonNull ConstraintAnalysis negate() { if (matches == null) { return new ConstraintAnalysis<>(constraintRef, weight.negate(), score.negate(), null, matchCount); @@ -72,9 +73,9 @@ ConstraintAnalysis negate() { } } - static > ConstraintAnalysis diff( - ConstraintRef constraintRef, ConstraintAnalysis constraintAnalysis, - ConstraintAnalysis otherConstraintAnalysis) { + static > @NonNull ConstraintAnalysis diff( + @NonNull ConstraintRef constraintRef, @Nullable ConstraintAnalysis constraintAnalysis, + @Nullable ConstraintAnalysis otherConstraintAnalysis) { if (constraintAnalysis == null) { if (otherConstraintAnalysis == null) { throw new IllegalStateException( @@ -214,10 +215,15 @@ Explanation of score (%s): @Override public String toString() { if (matches == null) { - return "(%s at %s, no matches)" - .formatted(score, weight); + if (matchCount == -1) { + return "(%s at %s, constraint matching disabled)" + .formatted(score, weight); + } else { + return "(%s at %s, %d matches, justifications disabled)" + .formatted(score, weight, matchCount); + } } else { - return "(%s at %s, %s matches)" + return "(%s at %s, %d matches with justifications)" .formatted(score, weight, matches.size()); } }