org.optaplanner.core.impl.score.definition

## Interface ScoreDefinition<S extends Score<S>>

- All Known Subinterfaces:
    FeasibilityScoreDefinition<S>, PlanningScore.NullScoreDefinition
  All Known Implementing Classes:
    AbstractBendableScoreDefinition, AbstractFeasibilityScoreDefinition, AbstractScoreDefinition, BendableBigDecimalScoreDefinition, BendableLongScoreDefinition, BendableScoreDefinition, HardMediumSoftBigDecimalScoreDefinition, HardMediumSoftLongScoreDefinition, HardMediumSoftScoreDefinition, HardSoftBigDecimalScoreDefinition, HardSoftDoubleScoreDefinition, HardSoftLongScoreDefinition, HardSoftScoreDefinition, SimpleBigDecimalScoreDefinition, SimpleDoubleScoreDefinition, SimpleLongScoreDefinition, SimpleScoreDefinition

      public interface ScoreDefinition<S extends Score<S>>

  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 and Description
    --- | ---
    `S` | `buildOptimisticBound(InitializingScoreTrend initializingScoreTrend, S score)` Builds a `Score` which is equal or better than any other `Score` with more variables initialized (while the already variables don't change).
    `S` | `buildPessimisticBound(InitializingScoreTrend initializingScoreTrend, S score)` Builds a `Score` which is equal or worse than any other `Score` with more variables initialized (while the already variables don't change).
    `ScoreHolder<S>` | `buildScoreHolder(boolean constraintMatchEnabled)` Used by `DroolsScoreDirector`.
    `ScoreInliner<S>` | `buildScoreInliner(boolean constraintMatchEnabled)` Used by `BavetConstraintFactory`
    `String` | `formatScore(S score)` Returns a `String` representation of the `Score`.
    `S` | `fromLevelNumbers(int initScore, Number[] levelNumbers)` The opposite 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.
    `S` | `getOneSoftestScore()` The score that represents the softest possible one.
    `Class<S>` | `getScoreClass()` Returns the `Class` of the actual `Score` implementation.
    `S` | `getZeroScore()` The score that represents zero.
    `default boolean` | `isNegativeOrZero(S score)`
    `default boolean` | `isPositiveOrZero(S score)`
    `S` | `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

    - #### 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<S> getScoreClass()

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

    - #### getZeroScore

          S getZeroScore()

      The score that represents zero.
      Returns:
        never null

    - #### getOneSoftestScore

          S getOneSoftestScore()

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

    - #### isPositiveOrZero

          default boolean isPositiveOrZero(S score)

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

    - #### isNegativeOrZero

          default boolean isNegativeOrZero(S score)

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

    - #### formatScore

          String formatScore(S score)

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

    - #### parseScore

          S 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

          S 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<S> buildScoreInliner(boolean constraintMatchEnabled)

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

    - #### buildScoreHolder

          ScoreHolder<S> buildScoreHolder(boolean constraintMatchEnabled)

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

    - #### buildOptimisticBound

          S buildOptimisticBound(InitializingScoreTrend initializingScoreTrend,
                                 S 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

          S buildPessimisticBound(InitializingScoreTrend initializingScoreTrend,
                                  S 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

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