org.optaplanner.core.api.score.holder

## Class AbstractScoreHolder<Score_ extends Score<Score_>>

- java.lang.Object
- - org.optaplanner.core.api.score.holder.AbstractScoreHolder<Score_>

- Type Parameters:
    `Score_` - the `Score` type
  All Implemented Interfaces:
    Serializable, ScoreHolder<Score_>
  Direct Known Subclasses:
    BendableBigDecimalScoreHolder, BendableLongScoreHolder, BendableScoreHolder, HardMediumSoftBigDecimalScoreHolder, HardMediumSoftLongScoreHolder, HardMediumSoftScoreHolder, HardSoftBigDecimalScoreHolder, HardSoftDoubleScoreHolder, HardSoftLongScoreHolder, HardSoftScoreHolder, SimpleBigDecimalScoreHolder, SimpleDoubleScoreHolder, SimpleLongScoreHolder, SimpleScoreHolder

      public abstract class AbstractScoreHolder<Score_ extends Score<Score_>>
      extends Object
      implements ScoreHolder<Score_>, Serializable

  Abstract superclass for `ScoreHolder`.
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `class` | `AbstractScoreHolder.ConstraintActivationUnMatchListener`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `constraintMatchEnabled`
    `protected Map<String,ConstraintMatchTotal>` | `constraintMatchTotalMap`
    `protected Map<Object,Indictment>` | `indictmentMap`
    `protected Score_` | `zeroScore`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractScoreHolder(boolean constraintMatchEnabled, Score_ zeroScore)`

  - ### Method Summary

    All Methods Instance Methods Concrete 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.
    `protected List<Object>` | `extractJustificationList(org.kie.api.runtime.rule.RuleContext kcontext)`
    `Map<String,ConstraintMatchTotal>` | `getConstraintMatchTotalMap()` Explains the `Score` of `ScoreHolder.extractScore(int)`.
    `Collection<ConstraintMatchTotal>` | `getConstraintMatchTotals()` Explains the `Score` of `ScoreHolder.extractScore(int)`.
    `Map<Object,Indictment>` | `getIndictmentMap()` Explains the impact of each planning entity or problem fact on the `Score`.
    `void` | `impactScore(org.kie.api.runtime.rule.RuleContext kcontext)` For internal use only, use penalize() or reward() instead.
    `void` | `impactScore(org.kie.api.runtime.rule.RuleContext kcontext, BigDecimal weightMultiplier)` For internal use only, use penalize() or reward() instead.
    `void` | `impactScore(org.kie.api.runtime.rule.RuleContext kcontext, int weightMultiplier)` For internal use only, use penalize() or reward() instead.
    `void` | `impactScore(org.kie.api.runtime.rule.RuleContext kcontext, long weightMultiplier)` For internal use only, use penalize() or reward() instead.
    `boolean` | `isConstraintMatchEnabled()` Must be in sync with `ScoreDirector.isConstraintMatchEnabled()` for the `ScoreDirector` which contains this `ScoreHolder`.
    `protected void` | `registerConstraintMatch(org.kie.api.runtime.rule.RuleContext kcontext, Runnable constraintUndoListener, Supplier<Score_> scoreSupplier)` Requires @`OptaPlannerRuleEventListener` to be added as event listener on `KieSession`, otherwise the score changes caused by the constraint matches would not be undone.
    `void` | `setJustificationListConverter(BiFunction<List<Object>,org.kie.api.definition.rule.Rule,List<Object>> converter)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.optaplanner.core.api.score.holder.ScoreHolder

      `extractScore`

- - ### Field Detail

    - #### constraintMatchEnabled

          protected final boolean constraintMatchEnabled

    - #### constraintMatchTotalMap

          protected final Map<String,ConstraintMatchTotal> constraintMatchTotalMap

    - #### indictmentMap

          protected final Map<Object,Indictment> indictmentMap

    - #### zeroScore

          protected final Score_ extends Score<Score_> zeroScore

  - ### Constructor Detail

    - #### AbstractScoreHolder

          protected AbstractScoreHolder(boolean constraintMatchEnabled,
                                        Score_ zeroScore)

  - ### Method Detail

    - #### isConstraintMatchEnabled

          public boolean isConstraintMatchEnabled()

      Description copied from interface: `ScoreHolder`
      Must be in sync with `ScoreDirector.isConstraintMatchEnabled()` for the `ScoreDirector` which contains this `ScoreHolder`.

      Defaults to true.

      Specified by:
        `isConstraintMatchEnabled` in interface `ScoreHolder<Score_ extends Score<Score_>>`
      Returns:
        false if the `ConstraintMatch`s and `ConstraintMatchTotal`s do not need to be collected which is a performance boost
      See Also:
        `ScoreHolder.getConstraintMatchTotals()`

    - #### getConstraintMatchTotals

          public Collection<ConstraintMatchTotal> getConstraintMatchTotals()

      Description copied from interface: `ScoreHolder`
      Explains the `Score` of `ScoreHolder.extractScore(int)`.

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

      Specified by:
        `getConstraintMatchTotals` in interface `ScoreHolder<Score_ extends Score<Score_>>`
      Returns:
        never null
      See Also:
        `ScoreDirector.getConstraintMatchTotals()`

    - #### getConstraintMatchTotalMap

          public Map<String,ConstraintMatchTotal> getConstraintMatchTotalMap()

      Description copied from interface: `ScoreHolder`
      Explains the `Score` of `ScoreHolder.extractScore(int)`.

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

      Specified by:
        `getConstraintMatchTotalMap` in interface `ScoreHolder<Score_ extends Score<Score_>>`
      Returns:
        never null
      See Also:
        `ScoreDirector.getConstraintMatchTotalMap()`

    - #### getIndictmentMap

          public Map<Object,Indictment> getIndictmentMap()

      Description copied from interface: `ScoreHolder`
      Explains the impact of each planning entity or problem fact on the `Score`.

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

      Specified by:
        `getIndictmentMap` in interface `ScoreHolder<Score_ extends Score<Score_>>`
      Returns:
        never null
      See Also:
        `ScoreDirector.getIndictmentMap()`

    - #### configureConstraintWeight

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

      Description copied from interface: `ScoreHolder`
      Sets up a `ConstraintWeight` from the `ConstraintConfiguration` during initialization.
      Specified by:
        `configureConstraintWeight` in interface `ScoreHolder<Score_ extends Score<Score_>>`
      Parameters:
        `rule` - never null
        `constraintWeight` - never null, with `Score.getInitScore()` equal to 0.

    - #### registerConstraintMatch

          protected void registerConstraintMatch(org.kie.api.runtime.rule.RuleContext kcontext,
                                                 Runnable constraintUndoListener,
                                                 Supplier<Score_> scoreSupplier)

      Requires @`OptaPlannerRuleEventListener` to be added as event listener on `KieSession`, otherwise the score changes caused by the constraint matches would not be undone. See `DroolsScoreDirector.resetKieSession()` for an example.
      Parameters:
        `kcontext` - The rule for which to register the match.
        `constraintUndoListener` - The operation to run to undo the match.
        `scoreSupplier` - The score change to be undone when constraint justification enabled.

    - #### impactScore

          public void impactScore(org.kie.api.runtime.rule.RuleContext kcontext)

      For internal use only, use penalize() or reward() instead.
      Parameters:
        `kcontext` - never null

    - #### impactScore

          public void impactScore(org.kie.api.runtime.rule.RuleContext kcontext,
                                  int weightMultiplier)

      For internal use only, use penalize() or reward() instead.
      Parameters:
        `kcontext` - never null
        `weightMultiplier` - any

    - #### impactScore

          public void impactScore(org.kie.api.runtime.rule.RuleContext kcontext,
                                  long weightMultiplier)

      For internal use only, use penalize() or reward() instead.
      Parameters:
        `kcontext` - never null
        `weightMultiplier` - any

    - #### impactScore

          public void impactScore(org.kie.api.runtime.rule.RuleContext kcontext,
                                  BigDecimal weightMultiplier)

      For internal use only, use penalize() or reward() instead.
      Parameters:
        `kcontext` - never null
        `weightMultiplier` - any

    - #### extractJustificationList

          protected List<Object> extractJustificationList(org.kie.api.runtime.rule.RuleContext kcontext)

    - #### setJustificationListConverter

          public void setJustificationListConverter(BiFunction<List<Object>,org.kie.api.definition.rule.Rule,List<Object>> converter)

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