Class AbstractConstraint<Solution_,Constraint_ extends AbstractConstraint<Solution_,Constraint_,ConstraintFactory_>,ConstraintFactory_ extends InnerConstraintFactory<Solution_,Constraint_>>
java.lang.Object
ai.timefold.solver.core.impl.score.stream.common.AbstractConstraint<Solution_,Constraint_,ConstraintFactory_>
- All Implemented Interfaces:
Constraint
- Direct Known Subclasses:
BavetConstraint
public abstract class AbstractConstraint<Solution_,Constraint_ extends AbstractConstraint<Solution_,Constraint_,ConstraintFactory_>,ConstraintFactory_ extends InnerConstraintFactory<Solution_,Constraint_>>
extends Object
implements Constraint
-
Field Summary
Fields inherited from interface ai.timefold.solver.core.api.score.stream.Constraint
DEFAULT_CONSTRAINT_GROUP -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractConstraint(ConstraintFactory_ constraintFactory, ConstraintRef constraintRef, String description, String constraintGroup, Score<?> defaultConstraintWeight, ScoreImpactType scoreImpactType, Object justificationMapping, Object indictedObjectsMapping) -
Method Summary
Modifier and TypeMethodDescriptionfinal voidassertCorrectImpact(int impact) final voidassertCorrectImpact(long impact) final voidassertCorrectImpact(BigDecimal impact) final <Score_ extends Score<Score_>>
Score_extractConstraintWeight(Solution_ solution) final ConstraintFactory_TheConstraintFactorythat built this.@NonNull String<Score_ extends Score<Score_>>
Score_Returns the weight of the constraint as defined in theConstraintProvider, without any overrides.@NonNull StringReturns a human-friendly description of the constraint.<IndictedObjectsMapping_>
IndictedObjectsMapping_<JustificationMapping_>
JustificationMapping_final ScoreImpactTypestatic <Solution_,Score_ extends Score<Score_>>
voidvalidateWeight(SolutionDescriptor<Solution_> solutionDescriptor, ConstraintRef constraintRef, Score_ constraintWeight) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ai.timefold.solver.core.api.score.stream.Constraint
getConstraintId, getConstraintName, getConstraintPackage
-
Constructor Details
-
AbstractConstraint
protected AbstractConstraint(ConstraintFactory_ constraintFactory, ConstraintRef constraintRef, String description, String constraintGroup, Score<?> defaultConstraintWeight, ScoreImpactType scoreImpactType, Object justificationMapping, Object indictedObjectsMapping) - Parameters:
constraintFactory- never nullconstraintRef- never nulldescription- never nullconstraintGroup- never nulldefaultConstraintWeight- if null, it means legacy constraint configuration code; will requireConstraintConfigurationto be present.scoreImpactType- never nulljustificationMapping- never nullindictedObjectsMapping- never null
-
-
Method Details
-
extractConstraintWeight
-
assertCorrectImpact
public final void assertCorrectImpact(int impact) -
assertCorrectImpact
public final void assertCorrectImpact(long impact) -
assertCorrectImpact
-
getConstraintFactory
Description copied from interface:ConstraintTheConstraintFactorythat built this.- Specified by:
getConstraintFactoryin interfaceConstraint- Returns:
- never null
-
getConstraintRef
- Specified by:
getConstraintRefin interfaceConstraint
-
getDescription
Description copied from interface:ConstraintReturns a human-friendly description of the constraint. The format of the description is left unspecified and will not be parsed in any way.- Specified by:
getDescriptionin interfaceConstraint- Returns:
- may be left empty
-
getConstraintGroup
- Specified by:
getConstraintGroupin interfaceConstraint
-
getConstraintWeight
Description copied from interface:ConstraintReturns the weight of the constraint as defined in theConstraintProvider, without any overrides.- Specified by:
getConstraintWeightin interfaceConstraint- Returns:
- null if the constraint does not have a weight defined
-
getScoreImpactType
-
getJustificationMapping
public <JustificationMapping_> JustificationMapping_ getJustificationMapping() -
getIndictedObjectsMapping
public <IndictedObjectsMapping_> IndictedObjectsMapping_ getIndictedObjectsMapping() -
validateWeight
public static <Solution_,Score_ extends Score<Score_>> void validateWeight(SolutionDescriptor<Solution_> solutionDescriptor, ConstraintRef constraintRef, Score_ constraintWeight)
-