org.optaplanner.core.api.score.holder

## Interface ScoreHolder<Score_ extends Score<Score_>>

- Type Parameters:
    `Score_` - the `Score` type
  All Known Implementing Classes:
    AbstractScoreHolder, BendableBigDecimalScoreHolder, BendableLongScoreHolder, BendableScoreHolder, HardMediumSoftBigDecimalScoreHolder, HardMediumSoftLongScoreHolder, HardMediumSoftScoreHolder, HardSoftBigDecimalScoreHolder, HardSoftDoubleScoreHolder, HardSoftLongScoreHolder, HardSoftScoreHolder, SimpleBigDecimalScoreHolder, SimpleDoubleScoreHolder, SimpleLongScoreHolder, SimpleScoreHolder

      public interface ScoreHolder<Score_ extends Score<Score_>>

  This class is injected as a global by `DroolsScoreDirector` into the Drools DRL. Other `ScoreDirector` implementations do not use this class.

  An implementation must extend `AbstractScoreHolder` to ensure backwards compatibility in future versions.

  See Also:
    `AbstractScoreHolder`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `configureConstraintWeight(org.kie.api.definition.rule.Rule rule, Score_ constraintWeight)` Sets up a `ConstraintWeight` from the `ConstraintConfiguration` during initialization.
    `Score_` | `extractScore(int initScore)` Extracts the `Score`, calculated by the `KieSession` for `DroolsScoreDirector`.
    `Map<String,ConstraintMatchTotal>` | `getConstraintMatchTotalMap()` Explains the `Score` of `extractScore(int)`.
    `Collection<ConstraintMatchTotal>` | `getConstraintMatchTotals()` Explains the `Score` of `extractScore(int)`.
    `Map<Object,Indictment>` | `getIndictmentMap()` Explains the impact of each planning entity or problem fact on the `Score`.
    `boolean` | `isConstraintMatchEnabled()` Must be in sync with `ScoreDirector.isConstraintMatchEnabled()` for the `ScoreDirector` which contains this `ScoreHolder`.

- - ### Method Detail

    - #### extractScore

          Score_ extractScore(int initScore)

      Extracts the `Score`, calculated by the `KieSession` for `DroolsScoreDirector`.

      Should not be called directly, use `ScoreDirector.calculateScore()` instead.

      Parameters:
        `initScore` - `<= 0`, managed by OptaPlanner, needed as a parameter in the `Score`'s creation method, see `Score.getInitScore()`
      Returns:
        never null, the `Score` of the working `PlanningSolution`

    - #### configureConstraintWeight

          void configureConstraintWeight(org.kie.api.definition.rule.Rule rule,
                                         Score_ constraintWeight)

      Sets up a `ConstraintWeight` from the `ConstraintConfiguration` during initialization.
      Parameters:
        `rule` - never null
        `constraintWeight` - never null, with `Score.getInitScore()` equal to 0.

    - #### isConstraintMatchEnabled

          boolean isConstraintMatchEnabled()

      Must be in sync with `ScoreDirector.isConstraintMatchEnabled()` for the `ScoreDirector` which contains this `ScoreHolder`.

      Defaults to true.

      Returns:
        false if the `ConstraintMatch`s and `ConstraintMatchTotal`s do not need to be collected which is a performance boost
      See Also:
        `getConstraintMatchTotals()`

    - #### getConstraintMatchTotals

          Collection<ConstraintMatchTotal> getConstraintMatchTotals()

      Explains the `Score` of `extractScore(int)`.

      Should not be called directly, use `ScoreDirector.getConstraintMatchTotals()` instead.

      Returns:
        never null
      Throws:
        `IllegalStateException` - if `isConstraintMatchEnabled()` is false
      See Also:
        `ScoreDirector.getConstraintMatchTotals()`

    - #### getConstraintMatchTotalMap

          Map<String,ConstraintMatchTotal> getConstraintMatchTotalMap()

      Explains the `Score` of `extractScore(int)`.

      Should not be called directly, use `ScoreDirector.getConstraintMatchTotalMap()` instead.

      Returns:
        never null
      Throws:
        `IllegalStateException` - if `isConstraintMatchEnabled()` is false
      See Also:
        `ScoreDirector.getConstraintMatchTotalMap()`

    - #### getIndictmentMap

          Map<Object,Indictment> getIndictmentMap()

      Explains the impact of each planning entity or problem fact on the `Score`.

      Should not be called directly, use `ScoreDirector.getIndictmentMap()` instead.

      Returns:
        never null
      Throws:
        `IllegalStateException` - if `isConstraintMatchEnabled()` returns false
      See Also:
        `ScoreDirector.getIndictmentMap()`

Copyright © 2006–2020 JBoss by Red Hat. All rights reserved.