diff --git a/core/src/main/java/ai/timefold/solver/core/impl/score/constraint/ConstraintMatchPolicy.java b/core/src/main/java/ai/timefold/solver/core/impl/score/constraint/ConstraintMatchPolicy.java index c194986514..3cc03cf7e0 100644 --- a/core/src/main/java/ai/timefold/solver/core/impl/score/constraint/ConstraintMatchPolicy.java +++ b/core/src/main/java/ai/timefold/solver/core/impl/score/constraint/ConstraintMatchPolicy.java @@ -10,9 +10,8 @@ public enum ConstraintMatchPolicy { public static ConstraintMatchPolicy match(ScoreAnalysisFetchPolicy scoreAnalysisFetchPolicy) { return switch (scoreAnalysisFetchPolicy) { + case FETCH_MATCH_COUNT, FETCH_SHALLOW -> ENABLED_WITHOUT_JUSTIFICATIONS; case FETCH_ALL -> ENABLED; - case FETCH_MATCH_COUNT -> ENABLED_WITHOUT_JUSTIFICATIONS; - case FETCH_SHALLOW -> DISABLED; }; } diff --git a/core/src/main/java/ai/timefold/solver/core/impl/score/director/stream/BavetConstraintStreamScoreDirector.java b/core/src/main/java/ai/timefold/solver/core/impl/score/director/stream/BavetConstraintStreamScoreDirector.java index 27ebf987a2..7cfa71b508 100644 --- a/core/src/main/java/ai/timefold/solver/core/impl/score/director/stream/BavetConstraintStreamScoreDirector.java +++ b/core/src/main/java/ai/timefold/solver/core/impl/score/director/stream/BavetConstraintStreamScoreDirector.java @@ -62,23 +62,23 @@ public Score_ calculateScore() { @Override public Map> getConstraintMatchTotalMap() { - if (workingSolution == null) { + if (!constraintMatchPolicy.isEnabled()) { + throw new IllegalStateException("When constraint matching is disabled, this method should not be called."); + } else if (workingSolution == null) { throw new IllegalStateException( "The method setWorkingSolution() must be called before the method getConstraintMatchTotalMap()."); - } else if (!constraintMatchPolicy.isEnabled()) { - throw new IllegalStateException("When constraint matching is disabled, this method should not be called."); } return session.getConstraintMatchTotalMap(); } @Override public Map> getIndictmentMap() { - if (workingSolution == null) { - throw new IllegalStateException( - "The method setWorkingSolution() must be called before the method getIndictmentMap()."); - } else if (!constraintMatchPolicy.isJustificationEnabled()) { + if (!constraintMatchPolicy.isJustificationEnabled()) { throw new IllegalStateException( "When constraint matching with justifications is disabled, this method should not be called."); + } else if (workingSolution == null) { + throw new IllegalStateException( + "The method setWorkingSolution() must be called before the method getIndictmentMap()."); } return session.getIndictmentMap(); }