public final class DroolsConstraintFactory<Solution_> extends Object implements InnerConstraintFactory<Solution_>
Constructor and Description |
---|
DroolsConstraintFactory(SolutionDescriptor<Solution_> solutionDescriptor) |
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() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
from
fromUniquePair, fromUniquePair, fromUniquePair, fromUniquePair, fromUniquePair
public DroolsConstraintFactory(SolutionDescriptor<Solution_> solutionDescriptor)
public <A> UniConstraintStream<A> fromUnfiltered(Class<A> fromClass)
ConstraintFactory
ConstraintFactory.from(Class)
,
but without any filtering of uninitialized planning entities
.fromUnfiltered
in interface ConstraintFactory
A
- the type of the matched problem fact or planning entity
fromClass
- never nullpublic <A> BiConstraintStream<A,A> fromUniquePair(Class<A> fromClass, BiJoiner<A,A> joiner)
ConstraintFactory
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.
fromUniquePair
in interface ConstraintFactory
A
- the type of the matched problem fact or planning entity
fromClass
- never nulljoiner
- never nullBiJoiner
is truepublic ConstraintSessionFactory<Solution_> buildSessionFactory(Constraint[] constraints)
InnerConstraintFactory
buildSessionFactory
in interface InnerConstraintFactory<Solution_>
constraints
- never nullpublic SolutionDescriptor<Solution_> getSolutionDescriptor()
getSolutionDescriptor
in interface InnerConstraintFactory<Solution_>
public int getNextRuleId()
Integer.MAX_VALUE
.
As long as rule creation calls this method in the same order, the rules will always receive the same ID.public String getDefaultConstraintPackage()
ConstraintFactory
ConstraintConfiguration.constraintPackage()
if available,
otherwise the package of the PlanningSolution
class.getDefaultConstraintPackage
in interface ConstraintFactory
Copyright © 2006–2019 JBoss by Red Hat. All rights reserved.