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

## Class DroolsConstraintFactory<Solution_>

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

- All Implemented Interfaces:
    ConstraintFactory, InnerConstraintFactory<Solution_>

      public final class DroolsConstraintFactory<Solution_>
      extends Object
      implements InnerConstraintFactory<Solution_>

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DroolsConstraintFactory(SolutionDescriptor<Solution_> solutionDescriptor)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `ConstraintSessionFactory<Solution_>` | `buildSessionFactory(Constraint[] constraints)` This method is thread-safe.
    `<A> UniConstraintStream<A>` | `fromUnfiltered(Class<A> fromClass)` Like `ConstraintFactory.from(Class)`, but without any filtering of uninitialized `planning entities`.
    `<A> BiConstraintStream<A,A>` | `fromUniquePair(Class<A> fromClass, BiJoiner<A,A> joiner)` Create a new `BiConstraintStream` for every unique combination of A and another A with a higher `PlanningId` for which the `BiJoiner` is true (for the properties it extracts from both facts).
    `String` | `getDefaultConstraintPackage()` This is `ConstraintConfiguration.constraintPackage()` if available, otherwise the package of the `PlanningSolution` class.
    `int` | `getNextRuleId()` The constraint creating code needs to call this method to retrieve an ID of the rule.
    `SolutionDescriptor<Solution_>` | `getSolutionDescriptor()`

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

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

    - ### Methods inherited from interface org.optaplanner.core.impl.score.stream.InnerConstraintFactory

      `from`

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

      `fromUniquePair, fromUniquePair, fromUniquePair, fromUniquePair, fromUniquePair`

- - ### Constructor Detail

    - #### DroolsConstraintFactory

          public DroolsConstraintFactory(SolutionDescriptor<Solution_> solutionDescriptor)

  - ### Method Detail

    - #### fromUnfiltered

          public <A> UniConstraintStream<A> fromUnfiltered(Class<A> fromClass)

      Description copied from interface: `ConstraintFactory`
      Like `ConstraintFactory.from(Class)`, but without any filtering of uninitialized `planning entities`.
      Specified by:
        `fromUnfiltered` in interface `ConstraintFactory`
      Type Parameters:
        `A` - the type of the matched problem fact or `planning entity`
      Parameters:
        `fromClass` - never null
      Returns:
        never null

    - #### fromUniquePair

          public <A> BiConstraintStream<A,A> fromUniquePair(Class<A> fromClass,
                                                            BiJoiner<A,A> joiner)

      Description copied from interface: `ConstraintFactory`
      Create a new `BiConstraintStream` for every unique combination of A and another A with a higher `PlanningId` for which the `BiJoiner` is true (for the properties it extracts from both facts).

      Important: This is faster and more scalable than not using a `ConstraintFactory.fromUniquePair(Class)` joiner} followed by a `filter`, because it applies hashing and/or indexing on the properties, so it doesn't create nor checks almost every combination of A and A.

      This method is syntactic sugar for `UniConstraintStream.join(Class, BiJoiner)`. It automatically adds a `lessThan` joiner on the `PlanningId` of A.

      This method has overloaded methods with multiple `BiJoiner` parameters.

      Specified by:
        `fromUniquePair` in interface `ConstraintFactory`
      Type Parameters:
        `A` - the type of the matched problem fact or `planning entity`
      Parameters:
        `fromClass` - never null
        `joiner` - never null
      Returns:
        a stream that matches every unique combination of A and another A for which the `BiJoiner` is true

    - #### buildSessionFactory

          public ConstraintSessionFactory<Solution_> buildSessionFactory(Constraint[] constraints)

      Description copied from interface: `InnerConstraintFactory`
      This method is thread-safe.
      Specified by:
        `buildSessionFactory` in interface `InnerConstraintFactory<Solution_>`
      Parameters:
        `constraints` - never null
      Returns:
        never null

    - #### getSolutionDescriptor

          public SolutionDescriptor<Solution_> getSolutionDescriptor()

      Specified by:
        `getSolutionDescriptor` in interface `InnerConstraintFactory<Solution_>`
      Returns:
        never null

    - #### getNextRuleId

          public int getNextRuleId()

      The constraint creating code needs to call this method to retrieve an ID of the rule. This ID then needs to be used in the rule name for easier debugging. It is imperative that this method only be called once per every rule created, as it maintains an internal counter of created rules. The sequence of IDs returned will start with 1 and continue towards `Integer.MAX_VALUE`. As long as rule creation calls this method in the same order, the rules will always receive the same ID.
      Returns:
        A unique numeric ID of the rule.

    - #### getDefaultConstraintPackage

          public String getDefaultConstraintPackage()

      Description copied from interface: `ConstraintFactory`
      This is `ConstraintConfiguration.constraintPackage()` if available, otherwise the package of the `PlanningSolution` class.
      Specified by:
        `getDefaultConstraintPackage` in interface `ConstraintFactory`
      Returns:
        never null

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