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
  • Constructor Details

    • AbstractConstraint

      protected AbstractConstraint(ConstraintFactory_ constraintFactory, ConstraintRef constraintRef, String description, String constraintGroup, Score<?> defaultConstraintWeight, ScoreImpactType scoreImpactType, Object justificationMapping, Object indictedObjectsMapping)
      Parameters:
      constraintFactory - never null
      constraintRef - never null
      description - never null
      constraintGroup - never null
      defaultConstraintWeight - if null, it means legacy constraint configuration code; will require ConstraintConfiguration to be present.
      scoreImpactType - never null
      justificationMapping - never null
      indictedObjectsMapping - never null
  • Method Details

    • extractConstraintWeight

      public final <Score_ extends Score<Score_>> Score_ extractConstraintWeight(Solution_ solution)
    • assertCorrectImpact

      public final void assertCorrectImpact(int impact)
    • assertCorrectImpact

      public final void assertCorrectImpact(long impact)
    • assertCorrectImpact

      public final void assertCorrectImpact(BigDecimal impact)
    • getConstraintFactory

      public final ConstraintFactory_ getConstraintFactory()
      Description copied from interface: Constraint
      The ConstraintFactory that built this.
      Specified by:
      getConstraintFactory in interface Constraint
      Returns:
      never null
    • getConstraintRef

      public ConstraintRef getConstraintRef()
      Specified by:
      getConstraintRef in interface Constraint
    • getDescription

      public @NonNull String getDescription()
      Description copied from interface: Constraint
      Returns 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:
      getDescription in interface Constraint
      Returns:
      may be left empty
    • getConstraintGroup

      public @NonNull String getConstraintGroup()
      Specified by:
      getConstraintGroup in interface Constraint
    • getConstraintWeight

      public <Score_ extends Score<Score_>> Score_ getConstraintWeight()
      Description copied from interface: Constraint
      Returns the weight of the constraint as defined in the ConstraintProvider, without any overrides.
      Specified by:
      getConstraintWeight in interface Constraint
      Returns:
      null if the constraint does not have a weight defined
    • getScoreImpactType

      public final ScoreImpactType 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)