org.optaplanner.core.impl.score.stream.drools

## Class DroolsConstraint<Solution_>

- java.lang.Object
- - org.optaplanner.core.impl.score.stream.drools.DroolsConstraint<Solution_>

- All Implemented Interfaces:
    Constraint

      public class DroolsConstraint<Solution_>
      extends Object
      implements Constraint

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DroolsConstraint(DroolsConstraintFactory<Solution_> constraintFactory, String constraintPackage, String constraintName, Function<Solution_,Score<?>> constraintWeightExtractor, boolean positive, List<DroolsFromUniConstraintStream<Solution_,Object>> fromStreamList, DroolsAbstractConstraintStream<Solution_> scoringStream)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `createRules(Map<DroolsAbstractConstraintStream<Solution_>,org.drools.model.Rule> ruleLibrary, org.drools.model.Global<? extends AbstractScoreHolder<?>> scoreHolderGlobal)` Creates Drools rules required to process this constraint.
    `Score<?>` | `extractConstraintWeight(Solution_ workingSolution)`
    `DroolsConstraintFactory<Solution_>` | `getConstraintFactory()` The `ConstraintFactory` that build this.
    `String` | `getConstraintName()` The constraint name.
    `String` | `getConstraintPackage()` The constraint package is the namespace of the constraint.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.optaplanner.core.api.score.stream.Constraint

      `getConstraintId`

- - ### Constructor Detail

    - #### DroolsConstraint

          public DroolsConstraint(DroolsConstraintFactory<Solution_> constraintFactory,
                                  String constraintPackage,
                                  String constraintName,
                                  Function<Solution_,Score<?>> constraintWeightExtractor,
                                  boolean positive,
                                  List<DroolsFromUniConstraintStream<Solution_,Object>> fromStreamList,
                                  DroolsAbstractConstraintStream<Solution_> scoringStream)

  - ### Method Detail

    - #### extractConstraintWeight

          public Score<?> extractConstraintWeight(Solution_ workingSolution)

    - #### createRules

          public void createRules(Map<DroolsAbstractConstraintStream<Solution_>,org.drools.model.Rule> ruleLibrary,
                                  org.drools.model.Global<? extends AbstractScoreHolder<?>> scoreHolderGlobal)

      Creates Drools rules required to process this constraint.
      Parameters:
        `ruleLibrary` - never null. Cache of rules already generated by previous constraints. This method uses `Map.computeIfAbsent(Object, Function)` to add rules from `DroolsAbstractConstraintStream`s which were not yet processed. This way, we will only generate one rule per stream, allowing Drools to reuse the computations.
        `scoreHolderGlobal` - never null. The Drools global used to track changes to score within rule consequences.

    - #### getConstraintFactory

          public DroolsConstraintFactory<Solution_> getConstraintFactory()

      Description copied from interface: `Constraint`
      The `ConstraintFactory` that build this.
      Specified by:
        `getConstraintFactory` in interface `Constraint`
      Returns:
        never null

    - #### getConstraintPackage

          public String getConstraintPackage()

      Description copied from interface: `Constraint`
      The constraint package is the namespace of the constraint.

      When using a `ConstraintConfiguration`, it is equal to the `ConstraintWeight.constraintPackage()`.

      Specified by:
        `getConstraintPackage` in interface `Constraint`
      Returns:
        never null

    - #### getConstraintName

          public String getConstraintName()

      Description copied from interface: `Constraint`
      The constraint name. It might not be unique, but `Constraint.getConstraintId()` is unique.

      When using a `ConstraintConfiguration`, it is equal to the `ConstraintWeight.value()`.

      Specified by:
        `getConstraintName` in interface `Constraint`
      Returns:
        never null

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2006–2019 JBoss by Red Hat. All rights reserved.