@@ -445,14 +445,19 @@ class ConstraintAnalysis(Generic[Score_]):
445445 but still non-zero constraint weight; non-empty if constraint has matches.
446446 This is a list to simplify access to individual elements,
447447 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.
449451 """
450452 _delegate : '_JavaConstraintAnalysis[Score_]'
451453
452454 def __init__ (self , delegate : '_JavaConstraintAnalysis[Score_]' ):
453455 self ._delegate = delegate
454456 delegate .constraintRef ()
455457
458+ def __str__ (self ):
459+ return self .summary
460+
456461 @property
457462 def constraint_ref (self ) -> ConstraintRef :
458463 return ConstraintRef (package_name = self ._delegate .constraintRef ().packageName (),
@@ -479,6 +484,9 @@ def matches(self) -> list[MatchAnalysis[Score_]]:
479484 def score (self ) -> Score_ :
480485 return to_python_score (self ._delegate .score ())
481486
487+ @property
488+ def summary (self ) -> str :
489+ return self ._delegate .summarize ()
482490
483491class ScoreAnalysis :
484492 """
@@ -510,6 +518,16 @@ class ScoreAnalysis:
510518 constraint_analyses : list[ConstraintAnalysis]
511519 Individual ConstraintAnalysis instances that make up this ScoreAnalysis.
512520
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+
513531 Notes
514532 -----
515533 the constructors of this record are off-limits.
@@ -520,6 +538,9 @@ class ScoreAnalysis:
520538 def __init__ (self , delegate : '_JavaScoreAnalysis' ):
521539 self ._delegate = delegate
522540
541+ def __str__ (self ):
542+ return self .summary
543+
523544 @property
524545 def score (self ) -> 'Score' :
525546 return to_python_score (self ._delegate .score ())
@@ -541,6 +562,10 @@ def constraint_analyses(self) -> list[ConstraintAnalysis]:
541562 list ['_JavaConstraintAnalysis[Score]' ], self ._delegate .constraintAnalyses ())
542563 ]
543564
565+ @property
566+ def summary (self ) -> str :
567+ return self ._delegate .summarize ()
568+
544569
545570__all__ = ['ScoreExplanation' ,
546571 'ConstraintRef' , 'ConstraintMatch' , 'ConstraintMatchTotal' ,
0 commit comments