Interface ScoreDefinition<Score_ extends Score<Score_>>
- Type Parameters:
Score_
- theScore
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_>>
-
Method Summary
Modifier and TypeMethodDescriptionbuildOptimisticBound
(InitializingScoreTrend initializingScoreTrend, Score_ score) buildPessimisticBound
(InitializingScoreTrend initializingScoreTrend, Score_ score) divideBySanitizedDivisor
(Score_ dividend, Score_ divisor) ReturnScore
whose every level is the result of dividing the matching levels in this and the divisor.formatScore
(Score_ score) fromLevelNumbers
(int initScore, Number[] levelNumbers) The opposite ofScore.toLevelNumbers()
.int
Returns the number of levels ofScore.toLevelNumbers()
.Returns the label forScore.initScore()
.String[]
Returns a label for each score level.int
Returns the length ofScore.toLevelNumbers()
for everyScore
of this definition.Class<?>
Return the type of number that the score implementation operates on.The score that represents the softest possible one.The score that represents zero.boolean
default boolean
isNegativeOrZero
(Score_ score) default boolean
isPositiveOrZero
(Score_ score) parseScore
(String scoreString)
-
Method Details
-
getInitLabel
String getInitLabel()Returns the label forScore.initScore()
.- Returns:
- never null
- See Also:
-
getLevelsSize
int getLevelsSize()Returns the length ofScore.toLevelNumbers()
for everyScore
of this definition. For example: returns 2 onHardSoftScoreDefinition
.- Returns:
- at least 1
-
getFeasibleLevelsSize
int getFeasibleLevelsSize()Returns the number of levels ofScore.toLevelNumbers()
. that are used to determineScore.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 "}
onHardSoftScoreDefinition
.It does not include the
getInitLabel()
.- Returns:
- never null, array with length of
getLevelsSize()
, each element is never null
-
getScoreClass
Returns theClass
of the actualScore
implementation. For example: returnsHardSoftScore.class
onHardSoftScoreDefinition
.- 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
- Parameters:
score
- never null- Returns:
- true if the score is higher or equal to
getZeroScore()
-
isNegativeOrZero
- Parameters:
score
- never null- Returns:
- true if the score is lower or equal to
getZeroScore()
-
formatScore
- Parameters:
score
- never null- Returns:
- never null
- See Also:
-
parseScore
- Parameters:
scoreString
- never null- Returns:
- never null
- See Also:
-
fromLevelNumbers
The opposite ofScore.toLevelNumbers()
.- Parameters:
initScore
-<= 0
, managed by OptaPlanner, needed as a parameter in theScore
's creation method, seeScore.initScore()
levelNumbers
- never null- Returns:
- never null
-
buildOptimisticBound
Builds aScore
which is equal or better than any otherScore
with more variables initialized (while the already variables don't change).- Parameters:
initializingScoreTrend
- never null, withInitializingScoreTrend.getLevelsSize()
equal togetLevelsSize()
.score
- never null, withScore.initScore()
0
.- Returns:
- never null
-
buildPessimisticBound
Builds aScore
which is equal or worse than any otherScore
with more variables initialized (while the already variables don't change).- Parameters:
initializingScoreTrend
- never null, withInitializingScoreTrend.getLevelsSize()
equal togetLevelsSize()
.score
- never null, withScore.initScore()
0
- Returns:
- never null
-
divideBySanitizedDivisor
ReturnScore
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 byMath.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
- 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.
-
getNumericType
Class<?> getNumericType()Return the type of number that the score implementation operates on. Examples:- int.class for
SimpleScore
- BigDecimal.class for
SimpleBigDecimalScore
- Returns:
- never null
- int.class for
-