Package org.optaplanner.core.impl.score.definition

## Interface ScoreDefinition<Score_ extends Score<Score_>>

- Type Parameters:
    `Score_` - the `Score` type
  All Known Subinterfaces:
    `PlanningScore.NullScoreDefinition`
  All Known Implementing Classes:
    `AbstractBendableScoreDefinition`, `AbstractScoreDefinition`, `BendableBigDecimalScoreDefinition`, `BendableLongScoreDefinition`, `BendableScoreDefinition`, `HardMediumSoftBigDecimalScoreDefinition`, `HardMediumSoftLongScoreDefinition`, `HardMediumSoftScoreDefinition`, `HardSoftBigDecimalScoreDefinition`, `HardSoftLongScoreDefinition`, `HardSoftScoreDefinition`, `SimpleBigDecimalScoreDefinition`, `SimpleLongScoreDefinition`, `SimpleScoreDefinition`

      public interface ScoreDefinition<Score_ extends Score<Score_>>

  A ScoreDefinition knows how to compare `Score`s and what the perfect maximum/minimum `Score` is.
  See Also:
    `AbstractScoreDefinition`, `HardSoftScoreDefinition`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `Score_` | `buildOptimisticBound​(InitializingScoreTrend initializingScoreTrend, Score_ score)` | Builds a `Score` which is equal or better than any other `Score` with more variables initialized (while the already variables don't change).
    `Score_` | `buildPessimisticBound​(InitializingScoreTrend initializingScoreTrend, Score_ score)` | Builds a `Score` which is equal or worse than any other `Score` with more variables initialized (while the already variables don't change).
    `AbstractScoreHolder<Score_>` | `buildScoreHolder​(boolean constraintMatchEnabled)` | Used by `DroolsScoreDirector`.
    `ScoreInliner<Score_>` | `buildScoreInliner​(boolean constraintMatchEnabled)` | Used by `BavetConstraintFactory`
    `Score_` | `divideBySanitizedDivisor​(Score_ dividend, Score_ divisor)` | Return `Score` whose every level is the result of dividing the matching levels in this and the divisor.
    `String` | `formatScore​(Score_ score)` | Returns a `String` representation of the `Score`.
    `Score_` | `fromLevelNumbers​(int initScore, Number[] levelNumbers)` | The opposite of `Score.toLevelNumbers()`.
    `int` | `getFeasibleLevelsSize()` | Returns the number of levels of `Score.toLevelNumbers()`.
    `String` | `getInitLabel()` | Returns the label for `Score.getInitScore()`.
    `String[]` | `getLevelLabels()` | Returns a label for each score level.
    `int` | `getLevelsSize()` | Returns the length of `Score.toLevelNumbers()` for every `Score` of this definition.
    `Score_` | `getOneSoftestScore()` | The score that represents the softest possible one.
    `Class<Score_>` | `getScoreClass()` | Returns the `Class` of the actual `Score` implementation.
    `Score_` | `getZeroScore()` | The score that represents zero.
    `boolean` | `isCompatibleArithmeticArgument​(Score score)` |
    `default boolean` | `isNegativeOrZero​(Score_ score)` |
    `default boolean` | `isPositiveOrZero​(Score_ score)` |
    `Score_` | `parseScore​(String scoreString)` | Parses the `String` and returns a `Score`.

- - ### Method Detail

    - #### getInitLabel

          String getInitLabel()

      Returns the label for `Score.getInitScore()`.
      Returns:
        never null
      See Also:
        `getLevelLabels()`

    - #### getLevelsSize

          int getLevelsSize()

      Returns the length of `Score.toLevelNumbers()` for every `Score` of this definition. For example: returns 2 on `HardSoftScoreDefinition`.
      Returns:
        at least 1

    - #### getFeasibleLevelsSize

          int getFeasibleLevelsSize()

      Returns the number of levels of `Score.toLevelNumbers()`. that are used to determine `Score.isFeasible()`.
      Returns:
        at least 0, at most `getLevelsSize()`

    - #### getLevelLabels

          String[] getLevelLabels()

      Returns a label for each score level. Each label includes the suffix "score" and must start in lower case. For example: returns `{"hard score", "soft score "}` on `HardSoftScoreDefinition`.

      It does not include the `getInitLabel()`.

      Returns:
        never null, array with length of `getLevelsSize()`, each element is never null

    - #### getScoreClass

          Class<Score_> getScoreClass()

      Returns the `Class` of the actual `Score` implementation. For example: returns `HardSoftScore.class` on `HardSoftScoreDefinition`.
      Returns:
        never null

    - #### getZeroScore

          Score_ getZeroScore()

      The score that represents zero.
      Returns:
        never null

    - #### getOneSoftestScore

          Score_ getOneSoftestScore()

      The score that represents the softest possible one.
      Returns:
        never null

    - #### isPositiveOrZero

          default boolean isPositiveOrZero​(Score_ score)

      Parameters:
        `score` - never null
      Returns:
        true if the score is higher or equal to `getZeroScore()`

    - #### isNegativeOrZero

          default boolean isNegativeOrZero​(Score_ score)

      Parameters:
        `score` - never null
      Returns:
        true if the score is lower or equal to `getZeroScore()`

    - #### formatScore

          String formatScore​(Score_ score)

      Returns a `String` representation of the `Score`.
      Parameters:
        `score` - never null
      Returns:
        never null
      See Also:
        `parseScore(String)`

    - #### parseScore

          Score_ parseScore​(String scoreString)

      Parses the `String` and returns a `Score`.
      Parameters:
        `scoreString` - never null
      Returns:
        never null
      See Also:
        `formatScore(Score)`, `ScoreUtils.parseScore(Class, String)`

    - #### fromLevelNumbers

          Score_ fromLevelNumbers​(int initScore,
                                  Number[] levelNumbers)

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

    - #### buildScoreInliner

          ScoreInliner<Score_> buildScoreInliner​(boolean constraintMatchEnabled)

      Used by `BavetConstraintFactory`
      Parameters:
        `constraintMatchEnabled` - true if `InnerScoreDirector.isConstraintMatchEnabled()` should be true
      Returns:
        never null

    - #### buildScoreHolder

          AbstractScoreHolder<Score_> buildScoreHolder​(boolean constraintMatchEnabled)

      Used by `DroolsScoreDirector`.
      Parameters:
        `constraintMatchEnabled` - true if`InnerScoreDirector.isConstraintMatchEnabled()` should be true
      Returns:
        never null

    - #### buildOptimisticBound

          Score_ buildOptimisticBound​(InitializingScoreTrend initializingScoreTrend,
                                      Score_ score)

      Builds a `Score` which is equal or better than any other `Score` with more variables initialized (while the already variables don't change).
      Parameters:
        `initializingScoreTrend` - never null, with `InitializingScoreTrend.getLevelsSize()` equal to `getLevelsSize()`.
        `score` - never null, with `Score.getInitScore()` `0`.
      Returns:
        never null

    - #### buildPessimisticBound

          Score_ buildPessimisticBound​(InitializingScoreTrend initializingScoreTrend,
                                       Score_ score)

      Builds a `Score` which is equal or worse than any other `Score` with more variables initialized (while the already variables don't change).
      Parameters:
        `initializingScoreTrend` - never null, with `InitializingScoreTrend.getLevelsSize()` equal to `getLevelsSize()`.
        `score` - never null, with `Score.getInitScore()` `0`
      Returns:
        never null

    - #### divideBySanitizedDivisor

          Score_ divideBySanitizedDivisor​(Score_ dividend,
                                          Score_ divisor)

      Return `Score` whose every level is the result of dividing the matching levels in this and the divisor. When rounding is needed, it is floored (as defined by `Math.floor(double)`).

      If any of the levels in the divisor are equal to zero, the method behaves as if they were equal to one instead.

      Parameters:
        `divisor` - value by which this Score is to be divided
      Returns:
        this / divisor

    - #### isCompatibleArithmeticArgument

          boolean isCompatibleArithmeticArgument​(Score score)

      Parameters:
        `score` - never null
      Returns:
        true if the otherScore is accepted as a parameter of `Score.add(Score)`, `Score.subtract(Score)` and `Comparable.compareTo(Object)` for scores of this score definition.