@@ -445,14 +445,19 @@ class ConstraintAnalysis(Generic[Score_]):
445
445
but still non-zero constraint weight; non-empty if constraint has matches.
446
446
This is a list to simplify access to individual elements,
447
447
but it contains no duplicates just like `set` wouldn't.
448
-
448
+ summary : str
449
+ Returns a diagnostic text
450
+ that explains part of the score quality through the ConstraintAnalysis API.
449
451
"""
450
452
_delegate : '_JavaConstraintAnalysis[Score_]'
451
453
452
454
def __init__ (self , delegate : '_JavaConstraintAnalysis[Score_]' ):
453
455
self ._delegate = delegate
454
456
delegate .constraintRef ()
455
457
458
+ def __str__ (self ):
459
+ return self .summary
460
+
456
461
@property
457
462
def constraint_ref (self ) -> ConstraintRef :
458
463
return ConstraintRef (package_name = self ._delegate .constraintRef ().packageName (),
@@ -479,6 +484,9 @@ def matches(self) -> list[MatchAnalysis[Score_]]:
479
484
def score (self ) -> Score_ :
480
485
return to_python_score (self ._delegate .score ())
481
486
487
+ @property
488
+ def summary (self ) -> str :
489
+ return self ._delegate .summarize ()
482
490
483
491
class ScoreAnalysis :
484
492
"""
@@ -510,6 +518,16 @@ class ScoreAnalysis:
510
518
constraint_analyses : list[ConstraintAnalysis]
511
519
Individual ConstraintAnalysis instances that make up this ScoreAnalysis.
512
520
521
+ summary : str
522
+ Returns a diagnostic text
523
+ that explains the solution through the `ConstraintMatch` API
524
+ to identify which constraints cause that score quality.
525
+
526
+ In case of an infeasible solution, this can help diagnose the cause of that.
527
+ Do not parse the return value, its format may change without warning.
528
+ Instead, to provide this information in a UI or a service,
529
+ use `constraint_analyses` and convert those into a domain-specific API.
530
+
513
531
Notes
514
532
-----
515
533
the constructors of this record are off-limits.
@@ -520,6 +538,9 @@ class ScoreAnalysis:
520
538
def __init__ (self , delegate : '_JavaScoreAnalysis' ):
521
539
self ._delegate = delegate
522
540
541
+ def __str__ (self ):
542
+ return self .summary
543
+
523
544
@property
524
545
def score (self ) -> 'Score' :
525
546
return to_python_score (self ._delegate .score ())
@@ -541,6 +562,10 @@ def constraint_analyses(self) -> list[ConstraintAnalysis]:
541
562
list ['_JavaConstraintAnalysis[Score]' ], self ._delegate .constraintAnalyses ())
542
563
]
543
564
565
+ @property
566
+ def summary (self ) -> str :
567
+ return self ._delegate .summarize ()
568
+
544
569
545
570
__all__ = ['ScoreExplanation' ,
546
571
'ConstraintRef' , 'ConstraintMatch' , 'ConstraintMatchTotal' ,
0 commit comments