org.optaplanner.core.impl.score.definition

## Class AbstractScoreDefinition<S extends Score<S>>

- java.lang.Object
- - org.optaplanner.core.impl.score.definition.AbstractScoreDefinition<S>

- All Implemented Interfaces:
    Serializable, ScoreDefinition<S>
  Direct Known Subclasses:
    AbstractBendableScoreDefinition, HardMediumSoftBigDecimalScoreDefinition, HardMediumSoftLongScoreDefinition, HardMediumSoftScoreDefinition, HardSoftBigDecimalScoreDefinition, HardSoftDoubleScoreDefinition, HardSoftLongScoreDefinition, HardSoftScoreDefinition, SimpleBigDecimalScoreDefinition, SimpleDoubleScoreDefinition, SimpleLongScoreDefinition, SimpleScoreDefinition

      public abstract class AbstractScoreDefinition<S extends Score<S>>
      extends Object
      implements ScoreDefinition<S>, Serializable

  Abstract superclass for `ScoreDefinition`.
  See Also:
    `ScoreDefinition`, `HardSoftScoreDefinition`, Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractScoreDefinition(String[] levelLabels)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected static BigDecimal` | `divide(BigDecimal dividend, BigDecimal divisor)`
    `protected static double` | `divide(double dividend, double divisor)`
    `protected static int` | `divide(int dividend, int divisor)`
    `protected static long` | `divide(long dividend, long divisor)`
    `String` | `formatScore(S score)` Returns a `String` representation of the `Score`.
    `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.
    `protected static BigDecimal` | `sanitize(BigDecimal number)`
    `protected static double` | `sanitize(double number)`
    `protected static int` | `sanitize(int number)`
    `protected static long` | `sanitize(long number)`
    `String` | `toString()`

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

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

    - ### Methods inherited from interface org.optaplanner.core.impl.score.definition.ScoreDefinition

      `buildOptimisticBound, buildPessimisticBound, buildScoreHolder, buildScoreInliner, divideBySanitizedDivisor, fromLevelNumbers, getFeasibleLevelsSize, getOneSoftestScore, getScoreClass, getZeroScore, isNegativeOrZero, isPositiveOrZero, parseScore`

- - ### Constructor Detail

    - #### AbstractScoreDefinition

          public AbstractScoreDefinition(String[] levelLabels)

      Parameters:
        `levelLabels` - never null, as defined by `ScoreDefinition.getLevelLabels()`

  - ### Method Detail

    - #### sanitize

          protected static int sanitize(int number)

    - #### sanitize

          protected static long sanitize(long number)

    - #### sanitize

          protected static double sanitize(double number)

    - #### sanitize

          protected static BigDecimal sanitize(BigDecimal number)

    - #### divide

          protected static int divide(int dividend,
                                      int divisor)

    - #### divide

          protected static long divide(long dividend,
                                       long divisor)

    - #### divide

          protected static double divide(double dividend,
                                         double divisor)

    - #### divide

          protected static BigDecimal divide(BigDecimal dividend,
                                             BigDecimal divisor)

    - #### getInitLabel

          public String getInitLabel()

      Description copied from interface: `ScoreDefinition`
      Returns the label for `Score.getInitScore()`.
      Specified by:
        `getInitLabel` in interface `ScoreDefinition<S extends Score<S>>`
      Returns:
        never null
      See Also:
        `ScoreDefinition.getLevelLabels()`

    - #### getLevelsSize

          public int getLevelsSize()

      Description copied from interface: `ScoreDefinition`
      Returns the length of `Score.toLevelNumbers()` for every `Score` of this definition. For example: returns 2 on `HardSoftScoreDefinition`.
      Specified by:
        `getLevelsSize` in interface `ScoreDefinition<S extends Score<S>>`
      Returns:
        at least 1

    - #### getLevelLabels

          public String[] getLevelLabels()

      Description copied from interface: `ScoreDefinition`
      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 `ScoreDefinition.getInitLabel()`.

      Specified by:
        `getLevelLabels` in interface `ScoreDefinition<S extends Score<S>>`
      Returns:
        never null, array with length of `ScoreDefinition.getLevelsSize()`, each element is never null

    - #### formatScore

          public String formatScore(S score)

      Description copied from interface: `ScoreDefinition`
      Returns a `String` representation of the `Score`.
      Specified by:
        `formatScore` in interface `ScoreDefinition<S extends Score<S>>`
      Parameters:
        `score` - never null
      Returns:
        never null
      See Also:
        `ScoreDefinition.parseScore(String)`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

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