77import ai .timefold .solver .core .api .score .stream .Constraint ;
88import ai .timefold .solver .core .api .score .stream .ConstraintJustification ;
99
10- import org .jspecify .annotations .NonNull ;
10+ import org .jspecify .annotations .NullMarked ;
1111import org .jspecify .annotations .Nullable ;
1212
13+ @ NullMarked
1314public interface SingleConstraintAssertion {
1415
1516 /**
@@ -19,9 +20,8 @@ public interface SingleConstraintAssertion {
1920 * @param message description of the scenario being asserted
2021 * @throws AssertionError when the expected penalty is not observed
2122 */
22- @ NonNull
2323 SingleConstraintAssertion justifiesWith (@ Nullable String message ,
24- @ NonNull ConstraintJustification @ NonNull ... justifications );
24+ ConstraintJustification ... justifications );
2525
2626 /**
2727 * Asserts that the {@link Constraint} being tested, given a set of facts, results in a given
@@ -30,7 +30,7 @@ SingleConstraintAssertion justifiesWith(@Nullable String message,
3030 * @param justifications the expected justifications.
3131 * @throws AssertionError when the expected penalty is not observed
3232 */
33- default @ NonNull SingleConstraintAssertion justifiesWith (@ NonNull ConstraintJustification @ NonNull ... justifications ) {
33+ default SingleConstraintAssertion justifiesWith (ConstraintJustification ... justifications ) {
3434 return justifiesWith (null , justifications );
3535 }
3636
@@ -41,9 +41,8 @@ SingleConstraintAssertion justifiesWith(@Nullable String message,
4141 * @param message description of the scenario being asserted
4242 * @throws AssertionError when the expected penalty is not observed
4343 */
44- @ NonNull
4544 SingleConstraintAssertion justifiesWithExactly (@ Nullable String message ,
46- @ NonNull ConstraintJustification @ NonNull ... justifications );
45+ ConstraintJustification ... justifications );
4746
4847 /**
4948 * Asserts that the {@link Constraint} being tested, given a set of facts, results in a given
@@ -52,8 +51,8 @@ SingleConstraintAssertion justifiesWithExactly(@Nullable String message,
5251 * @param justifications the expected justifications.
5352 * @throws AssertionError when the expected penalty is not observed
5453 */
55- default @ NonNull SingleConstraintAssertion
56- justifiesWithExactly (@ NonNull ConstraintJustification @ NonNull ... justifications ) {
54+ default SingleConstraintAssertion
55+ justifiesWithExactly (ConstraintJustification ... justifications ) {
5756 return justifiesWithExactly (null , justifications );
5857 }
5958
@@ -126,7 +125,7 @@ default void penalizesBy(long matchWeightTotal) {
126125 * @param matchWeightTotal at least 0, expected sum of match weights of matches of the constraint.
127126 * @throws AssertionError when the expected penalty is not observed
128127 */
129- default void penalizesBy (@ NonNull BigDecimal matchWeightTotal ) {
128+ default void penalizesBy (BigDecimal matchWeightTotal ) {
130129 penalizesBy (null , matchWeightTotal );
131130 }
132131
@@ -137,7 +136,7 @@ default void penalizesBy(@NonNull BigDecimal matchWeightTotal) {
137136 * @param matchWeightTotal at least 0, expected sum of match weights of matches of the constraint.
138137 * @throws AssertionError when the expected penalty is not observed
139138 */
140- void penalizesBy (@ Nullable String message , @ NonNull BigDecimal matchWeightTotal );
139+ void penalizesBy (@ Nullable String message , BigDecimal matchWeightTotal );
141140
142141 /**
143142 * Asserts that the {@link Constraint} being tested, given a set of facts, results in a given number of penalties.
@@ -232,7 +231,7 @@ default void rewardsWith(long matchWeightTotal) {
232231 * @param matchWeightTotal at least 0, expected sum of match weights of matches of the constraint.
233232 * @throws AssertionError when the expected reward is not observed
234233 */
235- default void rewardsWith (@ NonNull BigDecimal matchWeightTotal ) {
234+ default void rewardsWith (BigDecimal matchWeightTotal ) {
236235 rewardsWith (null , matchWeightTotal );
237236 }
238237
@@ -243,7 +242,7 @@ default void rewardsWith(@NonNull BigDecimal matchWeightTotal) {
243242 * @param matchWeightTotal at least 0, expected sum of match weights of matches of the constraint.
244243 * @throws AssertionError when the expected reward is not observed
245244 */
246- void rewardsWith (@ Nullable String message , @ NonNull BigDecimal matchWeightTotal );
245+ void rewardsWith (@ Nullable String message , BigDecimal matchWeightTotal );
247246
248247 /**
249248 * Asserts that the {@link Constraint} being tested, given a set of facts, results in a given number of rewards.
@@ -341,7 +340,7 @@ default void penalizesByMoreThan(long matchWeightTotal) {
341340 * @param matchWeightTotal at least 0, expected sum of match weights of matches of the constraint.
342341 * @throws AssertionError when the expected penalty is not observed
343342 */
344- default void penalizesByMoreThan (@ NonNull BigDecimal matchWeightTotal ) {
343+ default void penalizesByMoreThan (BigDecimal matchWeightTotal ) {
345344 penalizesByMoreThan (null , matchWeightTotal );
346345 }
347346
@@ -352,7 +351,7 @@ default void penalizesByMoreThan(@NonNull BigDecimal matchWeightTotal) {
352351 * @param matchWeightTotal at least 0, expected sum of match weights of matches of the constraint.
353352 * @throws AssertionError when the expected penalty is not observed
354353 */
355- void penalizesByMoreThan (@ Nullable String message , @ NonNull BigDecimal matchWeightTotal );
354+ void penalizesByMoreThan (@ Nullable String message , BigDecimal matchWeightTotal );
356355
357356 /**
358357 * Asserts that the {@link Constraint} being tested, given a set of facts,
@@ -431,7 +430,7 @@ default void rewardsWithMoreThan(long matchWeightTotal) {
431430 * @param matchWeightTotal at least 0, expected sum of match weights of matches of the constraint.
432431 * @throws AssertionError when the expected reward is not observed
433432 */
434- default void rewardsWithMoreThan (@ NonNull BigDecimal matchWeightTotal ) {
433+ default void rewardsWithMoreThan (BigDecimal matchWeightTotal ) {
435434 rewardsWithMoreThan (null , matchWeightTotal );
436435 }
437436
@@ -442,7 +441,7 @@ default void rewardsWithMoreThan(@NonNull BigDecimal matchWeightTotal) {
442441 * @param matchWeightTotal at least 0, expected sum of match weights of matches of the constraint.
443442 * @throws AssertionError when the expected reward is not observed
444443 */
445- void rewardsWithMoreThan (@ Nullable String message , @ NonNull BigDecimal matchWeightTotal );
444+ void rewardsWithMoreThan (@ Nullable String message , BigDecimal matchWeightTotal );
446445
447446 /**
448447 * Asserts that the {@link Constraint} being tested, given a set of facts,
@@ -522,7 +521,7 @@ default void penalizesByLessThan(long matchWeightTotal) {
522521 * @param matchWeightTotal at least 1, expected sum of match weights of matches of the constraint.
523522 * @throws AssertionError when the expected penalty is not observed
524523 */
525- default void penalizesByLessThan (@ NonNull BigDecimal matchWeightTotal ) {
524+ default void penalizesByLessThan (BigDecimal matchWeightTotal ) {
526525 penalizesByLessThan (null , matchWeightTotal );
527526 }
528527
@@ -533,7 +532,7 @@ default void penalizesByLessThan(@NonNull BigDecimal matchWeightTotal) {
533532 * @param matchWeightTotal at least 1, expected sum of match weights of matches of the constraint.
534533 * @throws AssertionError when the expected penalty is not observed
535534 */
536- void penalizesByLessThan (@ Nullable String message , @ NonNull BigDecimal matchWeightTotal );
535+ void penalizesByLessThan (@ Nullable String message , BigDecimal matchWeightTotal );
537536
538537 /**
539538 * Asserts that the {@link Constraint} being tested, given a set of facts,
@@ -612,7 +611,7 @@ default void rewardsWithLessThan(long matchWeightTotal) {
612611 * @param matchWeightTotal at least 1, expected sum of match weights of matches of the constraint.
613612 * @throws AssertionError when the expected reward is not observed
614613 */
615- default void rewardsWithLessThan (@ NonNull BigDecimal matchWeightTotal ) {
614+ default void rewardsWithLessThan (BigDecimal matchWeightTotal ) {
616615 rewardsWithLessThan (null , matchWeightTotal );
617616 }
618617
@@ -623,7 +622,7 @@ default void rewardsWithLessThan(@NonNull BigDecimal matchWeightTotal) {
623622 * @param matchWeightTotal at least 1, expected sum of match weights of matches of the constraint.
624623 * @throws AssertionError when the expected reward is not observed
625624 */
626- void rewardsWithLessThan (@ Nullable String message , @ NonNull BigDecimal matchWeightTotal );
625+ void rewardsWithLessThan (@ Nullable String message , BigDecimal matchWeightTotal );
627626
628627 /**
629628 * Asserts that the {@link Constraint} being tested, given a set of facts,
@@ -662,22 +661,21 @@ default void rewardsLessThan(long times) {
662661 * {@snippet :
663662 * HardSoftScore scoreA = constraintVerifier.verifyThat(MyConstraints::roomConflict)
664663 * .given(entity1, entity2)
665- * .score ();
664+ * .getScore ();
666665 * HardSoftScore scoreB = constraintVerifier.verifyThat(MyConstraints::roomConflict)
667666 * .given(entity3, entity4)
668- * .score ();
667+ * .getScore ();
669668 * assertThat(scoreA).isLessThan(scoreB);
670669 * }
671670 *
672671 * @return the score produced by this single constraint for the given facts, never null
673672 */
674- @ NonNull
675- <S extends Score <S >> S score ();
673+ <S extends Score <S >> S getScore ();
676674
677675 /**
678676 * Returns the match weight total of the {@link Constraint} being tested for the given set of facts.
679677 * <p>
680- * Unlike {@link #score ()}, which returns the full score (match weight × constraint weight),
678+ * Unlike {@link #getScore ()}, which returns the full score (match weight × constraint weight),
681679 * this method returns only the <b>match weight</b> — the same number you would pass
682680 * to assertion methods like {@link #penalizesBy(int)} or {@link #rewardsWith(int)}.
683681 * <p>
@@ -687,19 +685,18 @@ default void rewardsLessThan(long times) {
687685 * Usage example:
688686 *
689687 * {@snippet :
690- * Number impactA = constraintVerifier.verifyThat(MyConstraints::roomConflict)
688+ * var impactA = constraintVerifier.verifyThat(MyConstraints::roomConflict)
691689 * .given(entity1, entity2)
692- * .impact ();
693- * Number impactB = constraintVerifier.verifyThat(MyConstraints::roomConflict)
690+ * .getImpact ();
691+ * var impactB = constraintVerifier.verifyThat(MyConstraints::roomConflict)
694692 * .given(entity3, entity4)
695- * .impact ();
693+ * .getImpact ();
696694 * assertThat(impactA.intValue()).isGreaterThan(impactB.intValue());
697695 * }
698696 *
699697 * @return the match weight total produced by this single constraint, never null.
700698 * Positive for rewards, negative for penalties, zero when there is no impact.
701699 */
702- @ NonNull
703- Number impact ();
700+ Number getImpact ();
704701
705702}
0 commit comments