Class AbstractScoreDefinition<Score_ extends Score<Score_>>
- java.lang.Object
-
- org.optaplanner.core.impl.score.definition.AbstractScoreDefinition<Score_>
-
- All Implemented Interfaces:
ScoreDefinition<Score_>
- Direct Known Subclasses:
AbstractBendableScoreDefinition,HardMediumSoftBigDecimalScoreDefinition,HardMediumSoftLongScoreDefinition,HardMediumSoftScoreDefinition,HardSoftBigDecimalScoreDefinition,HardSoftLongScoreDefinition,HardSoftScoreDefinition,SimpleBigDecimalScoreDefinition,SimpleLongScoreDefinition,SimpleScoreDefinition
public abstract class AbstractScoreDefinition<Score_ extends Score<Score_>> extends Object implements ScoreDefinition<Score_>
Abstract superclass forScoreDefinition.- See Also:
ScoreDefinition,HardSoftScoreDefinition
-
-
Constructor Summary
Constructors Constructor Description AbstractScoreDefinition(String[] levelLabels)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static doubledivide(double dividend, double divisor)protected static intdivide(int dividend, int divisor)protected static longdivide(long dividend, long divisor)protected static BigDecimaldivide(BigDecimal dividend, BigDecimal divisor)StringformatScore(Score_ score)StringgetInitLabel()Returns the label forScore.getInitScore().String[]getLevelLabels()Returns a label for each score level.intgetLevelsSize()Returns the length ofScore.toLevelNumbers()for everyScoreof this definition.booleanisCompatibleArithmeticArgument(Score score)protected static intsanitize(int number)protected static longsanitize(long number)protected static BigDecimalsanitize(BigDecimal number)StringtoString()-
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, divideBySanitizedDivisor, fromLevelNumbers, getFeasibleLevelsSize, getOneSoftestScore, getScoreClass, getZeroScore, isNegativeOrZero, isPositiveOrZero, parseScore
-
-
-
-
Constructor Detail
-
AbstractScoreDefinition
public AbstractScoreDefinition(String[] levelLabels)
- Parameters:
levelLabels- never null, as defined byScoreDefinition.getLevelLabels()
-
-
Method Detail
-
sanitize
protected static int sanitize(int number)
-
sanitize
protected static long sanitize(long 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:ScoreDefinitionReturns the label forScore.getInitScore().- Specified by:
getInitLabelin interfaceScoreDefinition<Score_ extends Score<Score_>>- Returns:
- never null
- See Also:
ScoreDefinition.getLevelLabels()
-
getLevelsSize
public int getLevelsSize()
Description copied from interface:ScoreDefinitionReturns the length ofScore.toLevelNumbers()for everyScoreof this definition. For example: returns 2 onHardSoftScoreDefinition.- Specified by:
getLevelsSizein interfaceScoreDefinition<Score_ extends Score<Score_>>- Returns:
- at least 1
-
getLevelLabels
public String[] getLevelLabels()
Description copied from interface:ScoreDefinitionReturns 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 "}onHardSoftScoreDefinition.It does not include the
ScoreDefinition.getInitLabel().- Specified by:
getLevelLabelsin interfaceScoreDefinition<Score_ extends Score<Score_>>- Returns:
- never null, array with length of
ScoreDefinition.getLevelsSize(), each element is never null
-
formatScore
public String formatScore(Score_ score)
Description copied from interface:ScoreDefinition- Specified by:
formatScorein interfaceScoreDefinition<Score_ extends Score<Score_>>- Parameters:
score- never null- Returns:
- never null
- See Also:
ScoreDefinition.parseScore(String)
-
isCompatibleArithmeticArgument
public boolean isCompatibleArithmeticArgument(Score score)
- Specified by:
isCompatibleArithmeticArgumentin interfaceScoreDefinition<Score_ extends Score<Score_>>- Parameters:
score- never null- Returns:
- true if the otherScore is accepted as a parameter of
Score.add(Score),Score.subtract(Score)andComparable.compareTo(Object)for scores of this score definition.
-
-