public final class BendableLongScore extends AbstractScore<BendableLongScore> implements FeasibilityScore<BendableLongScore>
Score
is based on n levels of long constraints.
The number of levels is bendable at configuration time.
This class is immutable.
The getHardLevelsSize()
and getSoftLevelsSize()
must be the same as in the
BendableLongScoreDefinition
used.Score
,
Serialized FormModifier | Constructor and Description |
---|---|
protected |
BendableLongScore(long[] hardScores,
long[] softScores) |
Modifier and Type | Method and Description |
---|---|
BendableLongScore |
add(BendableLongScore augment)
Returns a Score whose value is (this + augment).
|
int |
compareTo(BendableLongScore other) |
BendableLongScore |
divide(double divisor)
Returns a Score whose value is (this / divisor).
|
boolean |
equals(Object o) |
int |
getHardLevelsSize() |
long |
getHardScore(int index) |
int |
getSoftLevelsSize() |
long |
getSoftScore(int index) |
int |
hashCode() |
boolean |
isCompatibleArithmeticArgument(Score otherScore) |
boolean |
isFeasible()
A
Solution is feasible if it has no broken hard constraints. |
BendableLongScore |
multiply(double multiplicand)
Returns a Score whose value is (this * multiplicand).
|
BendableLongScore |
negate()
Returns a Score whose value is (- this).
|
static BendableLongScore |
parseScore(int hardLevelsSize,
int softLevelsSize,
String scoreString) |
BendableLongScore |
power(double exponent)
Returns a Score whose value is (this ^ exponent).
|
BendableLongScore |
subtract(BendableLongScore subtrahend)
Returns a Score whose value is (this - subtrahend).
|
Number[] |
toLevelNumbers()
Returns an array of numbers representing the Score.
|
String |
toString() |
void |
validateCompatible(BendableLongScore other) |
static BendableLongScore |
valueOf(long[] hardScores,
long[] softScores)
Creates a new
BendableLongScore . |
buildScorePattern, buildScorePattern, parseLevelAsBigDecimal, parseLevelAsDouble, parseLevelAsInt, parseLevelAsLong, parseLevelStrings, parseLevelStrings
protected BendableLongScore(long[] hardScores, long[] softScores)
public static BendableLongScore parseScore(int hardLevelsSize, int softLevelsSize, String scoreString)
public static BendableLongScore valueOf(long[] hardScores, long[] softScores)
BendableLongScore
.hardScores
- never null, never change that array afterwards: it must be immutablesoftScores
- never null, never change that array afterwards: it must be immutablepublic int getHardLevelsSize()
public long getHardScore(int index)
index
- 0 <= index < getHardLevelsSize()
public int getSoftLevelsSize()
public long getSoftScore(int index)
index
- 0 <= index < getSoftLevelsSize()
public boolean isFeasible()
FeasibilityScore
Solution
is feasible if it has no broken hard constraints.isFeasible
in interface FeasibilityScore<BendableLongScore>
public BendableLongScore add(BendableLongScore augment)
Score
add
in interface Score<BendableLongScore>
augment
- value to be added to this Scorepublic BendableLongScore subtract(BendableLongScore subtrahend)
Score
subtract
in interface Score<BendableLongScore>
subtrahend
- value to be subtracted from this Scorepublic BendableLongScore multiply(double multiplicand)
Score
Math.floor(double)
.
/> If the implementation has a scale/precision, then the unspecified scale/precision of the double multiplicand should have no impact on the returned scale/precision.
multiply
in interface Score<BendableLongScore>
multiplicand
- value to be multiplied by this Score.public BendableLongScore divide(double divisor)
Score
Math.floor(double)
.
/> If the implementation has a scale/precision, then the unspecified scale/precision of the double divisor should have no impact on the returned scale/precision.
divide
in interface Score<BendableLongScore>
divisor
- value by which this Score is to be dividedpublic BendableLongScore power(double exponent)
Score
Math.floor(double)
.
/> If the implementation has a scale/precision, then the unspecified scale/precision of the double exponent should have no impact on the returned scale/precision.
power
in interface Score<BendableLongScore>
exponent
- value by which this Score is to be poweredpublic BendableLongScore negate()
Score
negate
in interface Score<BendableLongScore>
public Number[] toLevelNumbers()
Score
Math.floor(double)
.
The length of the returned array must be stable for a specific Score
implementation.
For example: -0hard/-7soft returns new int{-0, -7}toLevelNumbers
in interface Score<BendableLongScore>
public int compareTo(BendableLongScore other)
compareTo
in interface Comparable<BendableLongScore>
public void validateCompatible(BendableLongScore other)
public boolean isCompatibleArithmeticArgument(Score otherScore)
isCompatibleArithmeticArgument
in interface Score<BendableLongScore>
isCompatibleArithmeticArgument
in class AbstractScore<BendableLongScore>
otherScore
- never nullScore.add(Score)
, Score.subtract(Score)
and Comparable.compareTo(Object)
.Copyright © 2006-2015 JBoss by Red Hat. All Rights Reserved.