Interface ConstraintFactory
-
- All Known Subinterfaces:
InnerConstraintFactory<Solution_>
- All Known Implementing Classes:
BavetConstraintFactory
,DroolsConstraintFactory
public interface ConstraintFactory
WARNING: The ConstraintStreams/ConstraintProvider API is TECH PREVIEW. It works but it has many API gaps. Therefore, it is not rich enough yet to handle complex constraints.The factory to create every
ConstraintStream
(for example withfrom(Class)
) which ends in aConstraint
returned byConstraintProvider.defineConstraints(ConstraintFactory)
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description <A> UniConstraintStream<A>
from(Class<A> fromClass)
Start aConstraintStream
of all instances of the fromClass that are known asproblem facts
orplanning entities
.<A> UniConstraintStream<A>
fromUnfiltered(Class<A> fromClass)
Likefrom(Class)
, but without any filtering of uninitializedplanning entities
.default <A> BiConstraintStream<A,A>
fromUniquePair(Class<A> fromClass)
Create a newBiConstraintStream
for every unique combination of A and another A with a higherPlanningId
.<A> BiConstraintStream<A,A>
fromUniquePair(Class<A> fromClass, BiJoiner<A,A> joiner)
Create a newBiConstraintStream
for every unique combination of A and another A with a higherPlanningId
for which theBiJoiner
is true (for the properties it extracts from both facts).default <A> BiConstraintStream<A,A>
fromUniquePair(Class<A> fromClass, BiJoiner<A,A>... joiners)
As defined byfromUniquePair(Class, BiJoiner)
.default <A> BiConstraintStream<A,A>
fromUniquePair(Class<A> fromClass, BiJoiner<A,A> joiner1, BiJoiner<A,A> joiner2)
As defined byfromUniquePair(Class, BiJoiner)
.default <A> BiConstraintStream<A,A>
fromUniquePair(Class<A> fromClass, BiJoiner<A,A> joiner1, BiJoiner<A,A> joiner2, BiJoiner<A,A> joiner3)
As defined byfromUniquePair(Class, BiJoiner)
.default <A> BiConstraintStream<A,A>
fromUniquePair(Class<A> fromClass, BiJoiner<A,A> joiner1, BiJoiner<A,A> joiner2, BiJoiner<A,A> joiner3, BiJoiner<A,A> joiner4)
As defined byfromUniquePair(Class, BiJoiner)
.String
getDefaultConstraintPackage()
This isConstraintConfiguration.constraintPackage()
if available, otherwise the package of thePlanningSolution
class.
-
-
-
Method Detail
-
getDefaultConstraintPackage
String getDefaultConstraintPackage()
This isConstraintConfiguration.constraintPackage()
if available, otherwise the package of thePlanningSolution
class.- Returns:
- never null
-
from
<A> UniConstraintStream<A> from(Class<A> fromClass)
Start aConstraintStream
of all instances of the fromClass that are known asproblem facts
orplanning entities
.If the fromClass is a
PlanningEntity
, then it will be automaticallyfiltered
to only contain fully initialized entities, for which each genuinePlanningVariable
(of the fromClass or a superclass thereof) is initialized (so when the value is not null - unlessPlanningVariable.nullable()
is modified). This filtering will NOT automatically apply to genuine planning variables of subclass planning entities of the fromClass.- Type Parameters:
A
- the type of the matched problem fact orplanning entity
- Parameters:
fromClass
- never null- Returns:
- never null
-
fromUnfiltered
<A> UniConstraintStream<A> fromUnfiltered(Class<A> fromClass)
Likefrom(Class)
, but without any filtering of uninitializedplanning entities
.- Type Parameters:
A
- the type of the matched problem fact orplanning entity
- Parameters:
fromClass
- never null- Returns:
- never null
-
fromUniquePair
default <A> BiConstraintStream<A,A> fromUniquePair(Class<A> fromClass)
Create a newBiConstraintStream
for every unique combination of A and another A with a higherPlanningId
.Important:
Filtering
this is slower and less scalable than using ajoiner
, because it does barely applies hashing and/or indexing on the properties, so it creates and checks almost every combination of A and A.This method is syntactic sugar for
UniConstraintStream.join(Class)
. It automatically adds alessThan
joiner on thePlanningId
of A.- Type Parameters:
A
- the type of the matched problem fact orplanning entity
- Parameters:
fromClass
- never null- Returns:
- a stream that matches every unique combination of A and another A
-
fromUniquePair
<A> BiConstraintStream<A,A> fromUniquePair(Class<A> fromClass, BiJoiner<A,A> joiner)
Create a newBiConstraintStream
for every unique combination of A and another A with a higherPlanningId
for which theBiJoiner
is true (for the properties it extracts from both facts).Important: This is faster and more scalable than not using a
fromUniquePair(Class)
joiner} followed by afilter
, 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 alessThan
joiner on thePlanningId
of A.This method has overloaded methods with multiple
BiJoiner
parameters.- Type Parameters:
A
- the type of the matched problem fact orplanning entity
- Parameters:
fromClass
- never nulljoiner
- never null- Returns:
- a stream that matches every unique combination of A and another A for which the
BiJoiner
is true
-
fromUniquePair
default <A> BiConstraintStream<A,A> fromUniquePair(Class<A> fromClass, BiJoiner<A,A> joiner1, BiJoiner<A,A> joiner2)
As defined byfromUniquePair(Class, BiJoiner)
.- Type Parameters:
A
- the type of the matched problem fact orplanning entity
- Parameters:
fromClass
- never nulljoiner1
- never nulljoiner2
- never null- Returns:
- a stream that matches every unique combination of A and another A for which all the
joiners
are true
-
fromUniquePair
default <A> BiConstraintStream<A,A> fromUniquePair(Class<A> fromClass, BiJoiner<A,A> joiner1, BiJoiner<A,A> joiner2, BiJoiner<A,A> joiner3)
As defined byfromUniquePair(Class, BiJoiner)
.- Type Parameters:
A
- the type of the matched problem fact orplanning entity
- Parameters:
fromClass
- never nulljoiner1
- never nulljoiner2
- never nulljoiner3
- never null- Returns:
- a stream that matches every unique combination of A and another A for which all the
joiners
are true
-
fromUniquePair
default <A> BiConstraintStream<A,A> fromUniquePair(Class<A> fromClass, BiJoiner<A,A> joiner1, BiJoiner<A,A> joiner2, BiJoiner<A,A> joiner3, BiJoiner<A,A> joiner4)
As defined byfromUniquePair(Class, BiJoiner)
.- Type Parameters:
A
- the type of the matched problem fact orplanning entity
- Parameters:
fromClass
- never nulljoiner1
- never nulljoiner2
- never nulljoiner3
- never nulljoiner4
- never null- Returns:
- a stream that matches every unique combination of A and another A for which all the
joiners
are true
-
fromUniquePair
default <A> BiConstraintStream<A,A> fromUniquePair(Class<A> fromClass, BiJoiner<A,A>... joiners)
As defined byfromUniquePair(Class, BiJoiner)
.This method causes Unchecked generics array creation for varargs parameter warnings, but we can't fix it with a
SafeVarargs
annotation because it's an interface method. Therefore, there are overloaded methods with up to 4BiJoiner
parameters.- Type Parameters:
A
- the type of the matched problem fact orplanning entity
- Parameters:
fromClass
- never nulljoiners
- never null- Returns:
- a stream that matches every unique combination of A and another A for which all the
joiners
are true
-
-