Class BavetAbstractBiConstraintStream<Solution_,A,B>
- java.lang.Object
-
- org.optaplanner.core.impl.score.stream.common.AbstractConstraintStream<Solution_>
-
- org.optaplanner.core.impl.score.stream.bavet.common.BavetAbstractConstraintStream<Solution_>
-
- org.optaplanner.core.impl.score.stream.bavet.bi.BavetAbstractBiConstraintStream<Solution_,A,B>
-
- All Implemented Interfaces:
BiConstraintStream<A,B>
,ConstraintStream
,InnerBiConstraintStream<A,B>
- Direct Known Subclasses:
BavetFilterBiConstraintStream
,BavetGroupBiConstraintStream
,BavetGroupBridgeBiConstraintStream
,BavetJoinBiConstraintStream
,BavetJoinBridgeBiConstraintStream
,BavetScoringBiConstraintStream
public abstract class BavetAbstractBiConstraintStream<Solution_,A,B> extends BavetAbstractConstraintStream<Solution_> implements InnerBiConstraintStream<A,B>
-
-
Field Summary
Fields Modifier and Type Field Description protected List<BavetAbstractBiConstraintStream<Solution_,A,B>>
childStreamList
-
Fields inherited from class org.optaplanner.core.impl.score.stream.bavet.common.BavetAbstractConstraintStream
constraintFactory
-
-
Constructor Summary
Constructors Constructor Description BavetAbstractBiConstraintStream(BavetConstraintFactory<Solution_> constraintFactory, RetrievalSemantics retrievalSemantics)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
addChildStream(BavetAbstractBiConstraintStream<Solution_,A,B> childStream)
protected void
createChildNodeChains(BavetNodeBuildPolicy<Solution_> buildPolicy, Score<?> constraintWeight, BavetAbstractBiNode<A,B> node)
protected abstract BavetAbstractBiNode<A,B>
createNode(BavetNodeBuildPolicy<Solution_> buildPolicy, Score<?> constraintWeight, BavetAbstractBiNode<A,B> parentNode)
BavetAbstractBiNode<A,B>
createNodeChain(BavetNodeBuildPolicy<Solution_> buildPolicy, Score<?> constraintWeight, BavetAbstractBiNode<A,B> parentNode)
BavetAbstractBiConstraintStream<Solution_,A,B>
filter(BiPredicate<A,B> predicate)
Exhaustively test each tuple of facts against theBiPredicate
and match ifBiPredicate.test(Object, Object)
returns true.<ResultB_> BiConstraintStream<A,ResultB_>
flattenLast(Function<B,Iterable<ResultB_>> mapping)
Takes each tuple and applies a mapping on the last fact, which turns it intoIterable
.<GroupKey_>
UniConstraintStream<GroupKey_>groupBy(BiFunction<A,B,GroupKey_> groupKeyMapping)
Convert theBiConstraintStream
to aUniConstraintStream
, containing the set of tuples resulting from applying the group key mapping function on all tuples of the original stream.<GroupKey_,ResultContainer_,Result_>
BiConstraintStream<GroupKey_,Result_>groupBy(BiFunction<A,B,GroupKey_> groupKeyMapping, BiConstraintCollector<A,B,ResultContainer_,Result_> collector)
Convert theBiConstraintStream
to a differentBiConstraintStream
, consisting of unique tuples.<GroupKey_,ResultContainerB_,ResultB_,ResultContainerC_,ResultC_>
TriConstraintStream<GroupKey_,ResultB_,ResultC_>groupBy(BiFunction<A,B,GroupKey_> groupKeyMapping, BiConstraintCollector<A,B,ResultContainerB_,ResultB_> collectorB, BiConstraintCollector<A,B,ResultContainerC_,ResultC_> collectorC)
Convert theBiConstraintStream
to aTriConstraintStream
, consisting of unique tuples with three facts.<GroupKey_,ResultContainerB_,ResultB_,ResultContainerC_,ResultC_,ResultContainerD_,ResultD_>
QuadConstraintStream<GroupKey_,ResultB_,ResultC_,ResultD_>groupBy(BiFunction<A,B,GroupKey_> groupKeyMapping, BiConstraintCollector<A,B,ResultContainerB_,ResultB_> collectorB, BiConstraintCollector<A,B,ResultContainerC_,ResultC_> collectorC, BiConstraintCollector<A,B,ResultContainerD_,ResultD_> collectorD)
Convert theBiConstraintStream
to aQuadConstraintStream
, consisting of unique tuples with four facts.<GroupKeyA_,GroupKeyB_>
BiConstraintStream<GroupKeyA_,GroupKeyB_>groupBy(BiFunction<A,B,GroupKeyA_> groupKeyAMapping, BiFunction<A,B,GroupKeyB_> groupKeyBMapping)
Convert theBiConstraintStream
to a differentBiConstraintStream
, consisting of unique tuples.<GroupKeyA_,GroupKeyB_,GroupKeyC_>
TriConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_>groupBy(BiFunction<A,B,GroupKeyA_> groupKeyAMapping, BiFunction<A,B,GroupKeyB_> groupKeyBMapping, BiFunction<A,B,GroupKeyC_> groupKeyCMapping)
Convert theBiConstraintStream
to aTriConstraintStream
, consisting of unique tuples with three facts.<GroupKeyA_,GroupKeyB_,GroupKeyC_,GroupKeyD_>
QuadConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_,GroupKeyD_>groupBy(BiFunction<A,B,GroupKeyA_> groupKeyAMapping, BiFunction<A,B,GroupKeyB_> groupKeyBMapping, BiFunction<A,B,GroupKeyC_> groupKeyCMapping, BiFunction<A,B,GroupKeyD_> groupKeyDMapping)
Convert theBiConstraintStream
to aQuadConstraintStream
, consisting of unique tuples with four facts.<GroupKeyA_,GroupKeyB_,GroupKeyC_,ResultContainerD_,ResultD_>
QuadConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_,ResultD_>groupBy(BiFunction<A,B,GroupKeyA_> groupKeyAMapping, BiFunction<A,B,GroupKeyB_> groupKeyBMapping, BiFunction<A,B,GroupKeyC_> groupKeyCMapping, BiConstraintCollector<A,B,ResultContainerD_,ResultD_> collectorD)
Combines the semantics ofBiConstraintStream.groupBy(BiFunction, BiFunction)
andBiConstraintStream.groupBy(BiConstraintCollector)
.<GroupKeyA_,GroupKeyB_,ResultContainer_,Result_>
TriConstraintStream<GroupKeyA_,GroupKeyB_,Result_>groupBy(BiFunction<A,B,GroupKeyA_> groupKeyAMapping, BiFunction<A,B,GroupKeyB_> groupKeyBMapping, BiConstraintCollector<A,B,ResultContainer_,Result_> collector)
Combines the semantics ofBiConstraintStream.groupBy(BiFunction, BiFunction)
andBiConstraintStream.groupBy(BiConstraintCollector)
.<GroupKeyA_,GroupKeyB_,ResultContainerC_,ResultC_,ResultContainerD_,ResultD_>
QuadConstraintStream<GroupKeyA_,GroupKeyB_,ResultC_,ResultD_>groupBy(BiFunction<A,B,GroupKeyA_> groupKeyAMapping, BiFunction<A,B,GroupKeyB_> groupKeyBMapping, BiConstraintCollector<A,B,ResultContainerC_,ResultC_> collectorC, BiConstraintCollector<A,B,ResultContainerD_,ResultD_> collectorD)
Combines the semantics ofBiConstraintStream.groupBy(BiFunction, BiFunction)
andBiConstraintStream.groupBy(BiConstraintCollector)
.<ResultContainer_,Result_>
UniConstraintStream<Result_>groupBy(BiConstraintCollector<A,B,ResultContainer_,Result_> collector)
Runs all tuples of the stream through a given @BiConstraintCollector
and converts them into a newUniConstraintStream
which only has a single tuple, the result of applyingBiConstraintCollector
.<ResultContainerA_,ResultA_,ResultContainerB_,ResultB_>
BiConstraintStream<ResultA_,ResultB_>groupBy(BiConstraintCollector<A,B,ResultContainerA_,ResultA_> collectorA, BiConstraintCollector<A,B,ResultContainerB_,ResultB_> collectorB)
Convert theBiConstraintStream
to aBiConstraintStream
, containing only a single tuple, the result of applying twoBiConstraintCollector
s.<ResultContainerA_,ResultA_,ResultContainerB_,ResultB_,ResultContainerC_,ResultC_>
TriConstraintStream<ResultA_,ResultB_,ResultC_>groupBy(BiConstraintCollector<A,B,ResultContainerA_,ResultA_> collectorA, BiConstraintCollector<A,B,ResultContainerB_,ResultB_> collectorB, BiConstraintCollector<A,B,ResultContainerC_,ResultC_> collectorC)
Convert theBiConstraintStream
to aTriConstraintStream
, containing only a single tuple, the result of applying threeBiConstraintCollector
s.<ResultContainerA_,ResultA_,ResultContainerB_,ResultB_,ResultContainerC_,ResultC_,ResultContainerD_,ResultD_>
QuadConstraintStream<ResultA_,ResultB_,ResultC_,ResultD_>groupBy(BiConstraintCollector<A,B,ResultContainerA_,ResultA_> collectorA, BiConstraintCollector<A,B,ResultContainerB_,ResultB_> collectorB, BiConstraintCollector<A,B,ResultContainerC_,ResultC_> collectorC, BiConstraintCollector<A,B,ResultContainerD_,ResultD_> collectorD)
Convert theBiConstraintStream
to aQuadConstraintStream
, containing only a single tuple, the result of applying fourBiConstraintCollector
s.<C> BiConstraintStream<A,B>
ifExists(Class<C> otherClass, TriJoiner<A,B,C>... joiners)
As defined byBiConstraintStream.ifExists(Class, TriJoiner)
.<C> BiConstraintStream<A,B>
ifExistsIncludingNullVars(Class<C> otherClass, TriJoiner<A,B,C>... joiners)
<C> BiConstraintStream<A,B>
ifNotExists(Class<C> otherClass, TriJoiner<A,B,C>... joiners)
As defined byBiConstraintStream.ifNotExists(Class, TriJoiner)
.<C> BiConstraintStream<A,B>
ifNotExistsIncludingNullVars(Class<C> otherClass, TriJoiner<A,B,C>... joiners)
Constraint
impactScore(String constraintPackage, String constraintName, Score<?> constraintWeight, ToIntBiFunction<A,B> matchWeigher, ScoreImpactType impactType)
Constraint
impactScore(String constraintPackage, String constraintName, Score<?> constraintWeight, ScoreImpactType impactType)
Constraint
impactScoreBigDecimal(String constraintPackage, String constraintName, Score<?> constraintWeight, BiFunction<A,B,BigDecimal> matchWeigher, ScoreImpactType impactType)
Constraint
impactScoreConfigurable(String constraintPackage, String constraintName, ToIntBiFunction<A,B> matchWeigher, ScoreImpactType impactType)
Constraint
impactScoreConfigurable(String constraintPackage, String constraintName, ScoreImpactType impactType)
Constraint
impactScoreConfigurableBigDecimal(String constraintPackage, String constraintName, BiFunction<A,B,BigDecimal> matchWeigher, ScoreImpactType impactType)
Constraint
impactScoreConfigurableLong(String constraintPackage, String constraintName, ToLongBiFunction<A,B> matchWeigher, ScoreImpactType impactType)
Constraint
impactScoreLong(String constraintPackage, String constraintName, Score<?> constraintWeight, ToLongBiFunction<A,B> matchWeigher, ScoreImpactType impactType)
<C> TriConstraintStream<A,B,C>
join(Class<C> otherClass, TriJoiner<A,B,C>... joiners)
As defined byBiConstraintStream.join(Class, TriJoiner)
.<C> TriConstraintStream<A,B,C>
join(UniConstraintStream<C> otherStream, TriJoiner<A,B,C> joiner)
Create a newTriConstraintStream
for every combination of [A, B] and C for which theTriJoiner
is true (for the properties it extracts from both facts).<ResultA_> UniConstraintStream<ResultA_>
map(BiFunction<A,B,ResultA_> mapping)
As defined byUniConstraintStream.map(Function)
.protected BavetAbstractBiNode<A,B>
processNode(BavetNodeBuildPolicy<Solution_> buildPolicy, BavetAbstractBiNode<A,B> parentNode, BavetAbstractBiNode<A,B> node)
-
Methods inherited from class org.optaplanner.core.impl.score.stream.bavet.common.BavetAbstractConstraintStream
buildConstraint, buildConstraintConfigurable, getConstraintFactory, getFromStreamList
-
Methods inherited from class org.optaplanner.core.impl.score.stream.common.AbstractConstraintStream
buildConstraintWeightExtractor, buildConstraintWeightExtractor, getRetrievalSemantics, impact, penalize, penalizeConfigurable, reward, rewardConfigurable
-
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.api.score.stream.bi.BiConstraintStream
ifExists, ifExists, ifExists, ifExists, ifExistsIncludingNullVars, ifExistsIncludingNullVars, ifExistsIncludingNullVars, ifExistsIncludingNullVars, ifNotExists, ifNotExists, ifNotExists, ifNotExists, ifNotExistsIncludingNullVars, ifNotExistsIncludingNullVars, ifNotExistsIncludingNullVars, ifNotExistsIncludingNullVars, impact, impactBigDecimal, impactConfigurable, impactConfigurableBigDecimal, impactConfigurableLong, impactLong, join, join, join, join, join, join, join, join, join, penalize, penalizeBigDecimal, penalizeConfigurable, penalizeConfigurableBigDecimal, penalizeConfigurableLong, penalizeLong, reward, rewardBigDecimal, rewardConfigurable, rewardConfigurableBigDecimal, rewardConfigurableLong, rewardLong
-
Methods inherited from interface org.optaplanner.core.api.score.stream.ConstraintStream
getConstraintFactory, impact, impact, penalize, penalize, penalizeConfigurable, penalizeConfigurable, reward, reward, rewardConfigurable, rewardConfigurable
-
Methods inherited from interface org.optaplanner.core.impl.score.stream.bi.InnerBiConstraintStream
distinct, guaranteesDistinct, impact, impactBigDecimal, impactConfigurable, impactConfigurableBigDecimal, impactConfigurableLong, impactLong, join, penalize, penalizeBigDecimal, penalizeConfigurable, penalizeConfigurableBigDecimal, penalizeConfigurableLong, penalizeLong, reward, rewardBigDecimal, rewardConfigurable, rewardConfigurableBigDecimal, rewardConfigurableLong, rewardLong
-
-
-
-
Field Detail
-
childStreamList
protected final List<BavetAbstractBiConstraintStream<Solution_,A,B>> childStreamList
-
-
Constructor Detail
-
BavetAbstractBiConstraintStream
public BavetAbstractBiConstraintStream(BavetConstraintFactory<Solution_> constraintFactory, RetrievalSemantics retrievalSemantics)
-
-
Method Detail
-
addChildStream
protected void addChildStream(BavetAbstractBiConstraintStream<Solution_,A,B> childStream)
-
filter
public BavetAbstractBiConstraintStream<Solution_,A,B> filter(BiPredicate<A,B> predicate)
Description copied from interface:BiConstraintStream
Exhaustively test each tuple of facts against theBiPredicate
and match ifBiPredicate.test(Object, Object)
returns true.Important: This is slower and less scalable than
UniConstraintStream.join(UniConstraintStream, BiJoiner)
with a properBiJoiner
predicate (such asJoiners.equal(Function, Function)
, because the latter applies hashing and/or indexing, so it doesn't create every combination just to filter it out.- Specified by:
filter
in interfaceBiConstraintStream<Solution_,A>
- Parameters:
predicate
- never null- Returns:
- never null
-
join
public <C> TriConstraintStream<A,B,C> join(UniConstraintStream<C> otherStream, TriJoiner<A,B,C> joiner)
Description copied from interface:BiConstraintStream
Create a newTriConstraintStream
for every combination of [A, B] and C for which theTriJoiner
is true (for the properties it extracts from both facts).Important: This is faster and more scalable than a
join
followed by afilter
, because it applies hashing and/or indexing on the properties, so it doesn't create nor checks every combination of [A, B] and C.- Specified by:
join
in interfaceBiConstraintStream<Solution_,A>
- Type Parameters:
C
- the type of the third matched fact- Parameters:
otherStream
- never nulljoiner
- never null- Returns:
- never null, a stream that matches every combination of [A, B] and C for which the
TriFunction
is true
-
join
public <C> TriConstraintStream<A,B,C> join(Class<C> otherClass, TriJoiner<A,B,C>... joiners)
Description copied from interface:BiConstraintStream
As defined byBiConstraintStream.join(Class, TriJoiner)
. For performance reasons, indexing joiners must be placed before filtering joiners.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.- Specified by:
join
in interfaceBiConstraintStream<Solution_,A>
- Type Parameters:
C
- the type of the third matched fact- Parameters:
otherClass
- never nulljoiners
- never null- Returns:
- never null, a stream that matches every combination of [A, B] and C for which all the
joiners
are true
-
ifExists
@SafeVarargs public final <C> BiConstraintStream<A,B> ifExists(Class<C> otherClass, TriJoiner<A,B,C>... joiners)
Description copied from interface:BiConstraintStream
As defined byBiConstraintStream.ifExists(Class, TriJoiner)
. For performance reasons, indexing joiners must be placed before filtering joiners.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 4TriJoiner
parameters.- Specified by:
ifExists
in interfaceBiConstraintStream<Solution_,A>
- Type Parameters:
C
- the type of the third matched fact- Parameters:
otherClass
- never nulljoiners
- never null- Returns:
- never null, a stream that matches every pair of A and B where C exists for which the
TriJoiner
s are true
-
ifExistsIncludingNullVars
@SafeVarargs public final <C> BiConstraintStream<A,B> ifExistsIncludingNullVars(Class<C> otherClass, TriJoiner<A,B,C>... joiners)
Description copied from interface:BiConstraintStream
As defined byBiConstraintStream.ifExistsIncludingNullVars(Class, TriJoiner)
. For performance reasons, indexing joiners must be placed before filtering joiners.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 4TriJoiner
parameters.- Specified by:
ifExistsIncludingNullVars
in interfaceBiConstraintStream<Solution_,A>
- Type Parameters:
C
- the type of the third matched fact- Parameters:
otherClass
- never nulljoiners
- never null- Returns:
- never null, a stream that matches every pair of A and B where C exists for which the
TriJoiner
s are true
-
ifNotExists
@SafeVarargs public final <C> BiConstraintStream<A,B> ifNotExists(Class<C> otherClass, TriJoiner<A,B,C>... joiners)
Description copied from interface:BiConstraintStream
As defined byBiConstraintStream.ifNotExists(Class, TriJoiner)
. For performance reasons, indexing joiners must be placed before filtering joiners.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 4TriJoiner
parameters.- Specified by:
ifNotExists
in interfaceBiConstraintStream<Solution_,A>
- Type Parameters:
C
- the type of the third matched fact- Parameters:
otherClass
- never nulljoiners
- never null- Returns:
- never null, a stream that matches every pair of A and B where C does not exist for which the
TriJoiner
s are true
-
ifNotExistsIncludingNullVars
@SafeVarargs public final <C> BiConstraintStream<A,B> ifNotExistsIncludingNullVars(Class<C> otherClass, TriJoiner<A,B,C>... joiners)
Description copied from interface:BiConstraintStream
As defined byBiConstraintStream.ifNotExistsIncludingNullVars(Class, TriJoiner)
. For performance reasons, indexing joiners must be placed before filtering joiners.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 4TriJoiner
parameters.- Specified by:
ifNotExistsIncludingNullVars
in interfaceBiConstraintStream<Solution_,A>
- Type Parameters:
C
- the type of the third matched fact- Parameters:
otherClass
- never nulljoiners
- never null- Returns:
- never null, a stream that matches every pair of A and B where C does not exist for which the
TriJoiner
s are true
-
groupBy
public <ResultContainer_,Result_> UniConstraintStream<Result_> groupBy(BiConstraintCollector<A,B,ResultContainer_,Result_> collector)
Description copied from interface:BiConstraintStream
Runs all tuples of the stream through a given @BiConstraintCollector
and converts them into a newUniConstraintStream
which only has a single tuple, the result of applyingBiConstraintCollector
.- Specified by:
groupBy
in interfaceBiConstraintStream<Solution_,A>
- Type Parameters:
ResultContainer_
- the mutable accumulation type (often hidden as an implementation detail)Result_
- the type of a fact in the destinationUniConstraintStream
's tuple- Parameters:
collector
- never null, the collector to perform the grouping operation with SeeConstraintCollectors
for common operations, such ascount()
,sum()
and others.- Returns:
- never null
-
groupBy
public <ResultContainerA_,ResultA_,ResultContainerB_,ResultB_> BiConstraintStream<ResultA_,ResultB_> groupBy(BiConstraintCollector<A,B,ResultContainerA_,ResultA_> collectorA, BiConstraintCollector<A,B,ResultContainerB_,ResultB_> collectorB)
Description copied from interface:BiConstraintStream
Convert theBiConstraintStream
to aBiConstraintStream
, containing only a single tuple, the result of applying twoBiConstraintCollector
s.- Specified by:
groupBy
in interfaceBiConstraintStream<Solution_,A>
- Type Parameters:
ResultContainerA_
- the mutable accumulation type (often hidden as an implementation detail)ResultA_
- the type of the first fact in the destinationBiConstraintStream
's tupleResultContainerB_
- the mutable accumulation type (often hidden as an implementation detail)ResultB_
- the type of the second fact in the destinationBiConstraintStream
's tuple- Parameters:
collectorA
- never null, the collector to perform the first grouping operation with SeeConstraintCollectors
for common operations, such ascount()
,sum()
and others.collectorB
- never null, the collector to perform the second grouping operation with SeeConstraintCollectors
for common operations, such ascount()
,sum()
and others.- Returns:
- never null
-
groupBy
public <ResultContainerA_,ResultA_,ResultContainerB_,ResultB_,ResultContainerC_,ResultC_> TriConstraintStream<ResultA_,ResultB_,ResultC_> groupBy(BiConstraintCollector<A,B,ResultContainerA_,ResultA_> collectorA, BiConstraintCollector<A,B,ResultContainerB_,ResultB_> collectorB, BiConstraintCollector<A,B,ResultContainerC_,ResultC_> collectorC)
Description copied from interface:BiConstraintStream
Convert theBiConstraintStream
to aTriConstraintStream
, containing only a single tuple, the result of applying threeBiConstraintCollector
s.- Specified by:
groupBy
in interfaceBiConstraintStream<Solution_,A>
- Type Parameters:
ResultContainerA_
- the mutable accumulation type (often hidden as an implementation detail)ResultA_
- the type of the first fact in the destinationTriConstraintStream
's tupleResultContainerB_
- the mutable accumulation type (often hidden as an implementation detail)ResultB_
- the type of the second fact in the destinationTriConstraintStream
's tupleResultContainerC_
- the mutable accumulation type (often hidden as an implementation detail)ResultC_
- the type of the third fact in the destinationTriConstraintStream
's tuple- Parameters:
collectorA
- never null, the collector to perform the first grouping operation with SeeConstraintCollectors
for common operations, such ascount()
,sum()
and others.collectorB
- never null, the collector to perform the second grouping operation with SeeConstraintCollectors
for common operations, such ascount()
,sum()
and others.collectorC
- never null, the collector to perform the third grouping operation with SeeConstraintCollectors
for common operations, such ascount()
,sum()
and others.- Returns:
- never null
-
groupBy
public <ResultContainerA_,ResultA_,ResultContainerB_,ResultB_,ResultContainerC_,ResultC_,ResultContainerD_,ResultD_> QuadConstraintStream<ResultA_,ResultB_,ResultC_,ResultD_> groupBy(BiConstraintCollector<A,B,ResultContainerA_,ResultA_> collectorA, BiConstraintCollector<A,B,ResultContainerB_,ResultB_> collectorB, BiConstraintCollector<A,B,ResultContainerC_,ResultC_> collectorC, BiConstraintCollector<A,B,ResultContainerD_,ResultD_> collectorD)
Description copied from interface:BiConstraintStream
Convert theBiConstraintStream
to aQuadConstraintStream
, containing only a single tuple, the result of applying fourBiConstraintCollector
s.- Specified by:
groupBy
in interfaceBiConstraintStream<Solution_,A>
- Type Parameters:
ResultContainerA_
- the mutable accumulation type (often hidden as an implementation detail)ResultA_
- the type of the first fact in the destinationQuadConstraintStream
's tupleResultContainerB_
- the mutable accumulation type (often hidden as an implementation detail)ResultB_
- the type of the second fact in the destinationQuadConstraintStream
's tupleResultContainerC_
- the mutable accumulation type (often hidden as an implementation detail)ResultC_
- the type of the third fact in the destinationQuadConstraintStream
's tupleResultContainerD_
- the mutable accumulation type (often hidden as an implementation detail)ResultD_
- the type of the fourth fact in the destinationQuadConstraintStream
's tuple- Parameters:
collectorA
- never null, the collector to perform the first grouping operation with SeeConstraintCollectors
for common operations, such ascount()
,sum()
and others.collectorB
- never null, the collector to perform the second grouping operation with SeeConstraintCollectors
for common operations, such ascount()
,sum()
and others.collectorC
- never null, the collector to perform the third grouping operation with SeeConstraintCollectors
for common operations, such ascount()
,sum()
and others.collectorD
- never null, the collector to perform the fourth grouping operation with SeeConstraintCollectors
for common operations, such ascount()
,sum()
and others.- Returns:
- never null
-
groupBy
public <GroupKey_> UniConstraintStream<GroupKey_> groupBy(BiFunction<A,B,GroupKey_> groupKeyMapping)
Description copied from interface:BiConstraintStream
Convert theBiConstraintStream
to aUniConstraintStream
, containing the set of tuples resulting from applying the group key mapping function on all tuples of the original stream. Neither tuple of the new streamObjects.equals(Object, Object)
any other.- Specified by:
groupBy
in interfaceBiConstraintStream<Solution_,A>
- Type Parameters:
GroupKey_
- the type of a fact in the destinationUniConstraintStream
's tuple- Parameters:
groupKeyMapping
- never null, mapping function to convert each element in the stream to a different element- Returns:
- never null
-
groupBy
public <GroupKey_,ResultContainerB_,ResultB_,ResultContainerC_,ResultC_> TriConstraintStream<GroupKey_,ResultB_,ResultC_> groupBy(BiFunction<A,B,GroupKey_> groupKeyMapping, BiConstraintCollector<A,B,ResultContainerB_,ResultB_> collectorB, BiConstraintCollector<A,B,ResultContainerC_,ResultC_> collectorC)
Description copied from interface:BiConstraintStream
Convert theBiConstraintStream
to aTriConstraintStream
, consisting of unique tuples with three facts.The first fact is the return value of the group key mapping function, applied on the incoming tuple. The remaining facts are the return value of the respective
BiConstraintCollector
applied on all incoming tuples with the same first fact.- Specified by:
groupBy
in interfaceBiConstraintStream<Solution_,A>
- Type Parameters:
GroupKey_
- the type of the first fact in the destinationTriConstraintStream
's tupleResultContainerB_
- the mutable accumulation type (often hidden as an implementation detail)ResultB_
- the type of the second fact in the destinationTriConstraintStream
's tupleResultContainerC_
- the mutable accumulation type (often hidden as an implementation detail)ResultC_
- the type of the third fact in the destinationTriConstraintStream
's tuple- Parameters:
groupKeyMapping
- never null, function to convert the fact in the original tuple to a different factcollectorB
- never null, the collector to perform the first grouping operation with SeeConstraintCollectors
for common operations, such ascount()
,sum()
and others.collectorC
- never null, the collector to perform the second grouping operation with SeeConstraintCollectors
for common operations, such ascount()
,sum()
and others.- Returns:
- never null
-
groupBy
public <GroupKey_,ResultContainerB_,ResultB_,ResultContainerC_,ResultC_,ResultContainerD_,ResultD_> QuadConstraintStream<GroupKey_,ResultB_,ResultC_,ResultD_> groupBy(BiFunction<A,B,GroupKey_> groupKeyMapping, BiConstraintCollector<A,B,ResultContainerB_,ResultB_> collectorB, BiConstraintCollector<A,B,ResultContainerC_,ResultC_> collectorC, BiConstraintCollector<A,B,ResultContainerD_,ResultD_> collectorD)
Description copied from interface:BiConstraintStream
Convert theBiConstraintStream
to aQuadConstraintStream
, consisting of unique tuples with four facts.The first fact is the return value of the group key mapping function, applied on the incoming tuple. The remaining facts are the return value of the respective
BiConstraintCollector
applied on all incoming tuples with the same first fact.- Specified by:
groupBy
in interfaceBiConstraintStream<Solution_,A>
- Type Parameters:
GroupKey_
- the type of the first fact in the destinationQuadConstraintStream
's tupleResultContainerB_
- the mutable accumulation type (often hidden as an implementation detail)ResultB_
- the type of the second fact in the destinationQuadConstraintStream
's tupleResultContainerC_
- the mutable accumulation type (often hidden as an implementation detail)ResultC_
- the type of the third fact in the destinationQuadConstraintStream
's tupleResultContainerD_
- the mutable accumulation type (often hidden as an implementation detail)ResultD_
- the type of the fourth fact in the destinationQuadConstraintStream
's tuple- Parameters:
groupKeyMapping
- never null, function to convert the fact in the original tuple to a different factcollectorB
- never null, the collector to perform the first grouping operation with SeeConstraintCollectors
for common operations, such ascount()
,sum()
and others.collectorC
- never null, the collector to perform the second grouping operation with SeeConstraintCollectors
for common operations, such ascount()
,sum()
and others.collectorD
- never null, the collector to perform the third grouping operation with SeeConstraintCollectors
for common operations, such ascount()
,sum()
and others.- Returns:
- never null
-
groupBy
public <GroupKey_,ResultContainer_,Result_> BiConstraintStream<GroupKey_,Result_> groupBy(BiFunction<A,B,GroupKey_> groupKeyMapping, BiConstraintCollector<A,B,ResultContainer_,Result_> collector)
Description copied from interface:BiConstraintStream
Convert theBiConstraintStream
to a differentBiConstraintStream
, consisting of unique tuples.The first fact is the return value of the group key mapping function, applied on the incoming tuple. The second fact is the return value of a given
BiConstraintCollector
applied on all incoming tuples with the same first fact.- Specified by:
groupBy
in interfaceBiConstraintStream<Solution_,A>
- Type Parameters:
GroupKey_
- the type of the first fact in the destinationBiConstraintStream
's tupleResultContainer_
- the mutable accumulation type (often hidden as an implementation detail)Result_
- the type of the second fact in the destinationBiConstraintStream
's tuple- Parameters:
groupKeyMapping
- never null, function to convert the fact in the original tuple to a different factcollector
- never null, the collector to perform the grouping operation with SeeConstraintCollectors
for common operations, such ascount()
,sum()
and others.- Returns:
- never null
-
groupBy
public <GroupKeyA_,GroupKeyB_> BiConstraintStream<GroupKeyA_,GroupKeyB_> groupBy(BiFunction<A,B,GroupKeyA_> groupKeyAMapping, BiFunction<A,B,GroupKeyB_> groupKeyBMapping)
Description copied from interface:BiConstraintStream
Convert theBiConstraintStream
to a differentBiConstraintStream
, consisting of unique tuples.The first fact is the return value of the first group key mapping function, applied on the incoming tuple. The second fact is the return value of the second group key mapping function, applied on all incoming tuples with the same first fact.
- Specified by:
groupBy
in interfaceBiConstraintStream<Solution_,A>
- Type Parameters:
GroupKeyA_
- the type of the first fact in the destinationBiConstraintStream
's tupleGroupKeyB_
- the type of the second fact in the destinationBiConstraintStream
's tuple- Parameters:
groupKeyAMapping
- never null, function to convert the facts in the original tuple to a new factgroupKeyBMapping
- never null, function to convert the facts in the original tuple to another new fact- Returns:
- never null
-
groupBy
public <GroupKeyA_,GroupKeyB_,ResultContainer_,Result_> TriConstraintStream<GroupKeyA_,GroupKeyB_,Result_> groupBy(BiFunction<A,B,GroupKeyA_> groupKeyAMapping, BiFunction<A,B,GroupKeyB_> groupKeyBMapping, BiConstraintCollector<A,B,ResultContainer_,Result_> collector)
Description copied from interface:BiConstraintStream
Combines the semantics ofBiConstraintStream.groupBy(BiFunction, BiFunction)
andBiConstraintStream.groupBy(BiConstraintCollector)
. That is, the first and second facts in the tuple follow theBiConstraintStream.groupBy(BiFunction, BiFunction)
semantics, and the third fact is the result of applyingBiConstraintCollector.finisher()
on all the tuples of the originalUniConstraintStream
that belong to the group.- Specified by:
groupBy
in interfaceBiConstraintStream<Solution_,A>
- Type Parameters:
GroupKeyA_
- the type of the first fact in the destinationTriConstraintStream
's tupleGroupKeyB_
- the type of the second fact in the destinationTriConstraintStream
's tupleResultContainer_
- the mutable accumulation type (often hidden as an implementation detail)Result_
- the type of the third fact in the destinationTriConstraintStream
's tuple- Parameters:
groupKeyAMapping
- never null, function to convert the original tuple into a first factgroupKeyBMapping
- never null, function to convert the original tuple into a second factcollector
- never null, the collector to perform the grouping operation with SeeConstraintCollectors
for common operations, such ascount()
,sum()
and others.- Returns:
- never null
-
groupBy
public <GroupKeyA_,GroupKeyB_,ResultContainerC_,ResultC_,ResultContainerD_,ResultD_> QuadConstraintStream<GroupKeyA_,GroupKeyB_,ResultC_,ResultD_> groupBy(BiFunction<A,B,GroupKeyA_> groupKeyAMapping, BiFunction<A,B,GroupKeyB_> groupKeyBMapping, BiConstraintCollector<A,B,ResultContainerC_,ResultC_> collectorC, BiConstraintCollector<A,B,ResultContainerD_,ResultD_> collectorD)
Description copied from interface:BiConstraintStream
Combines the semantics ofBiConstraintStream.groupBy(BiFunction, BiFunction)
andBiConstraintStream.groupBy(BiConstraintCollector)
. That is, the first and second facts in the tuple follow theBiConstraintStream.groupBy(BiFunction, BiFunction)
semantics. The third fact is the result of applying the firstBiConstraintCollector.finisher()
on all the tuples of the originalBiConstraintStream
that belong to the group. The fourth fact is the result of applying the secondBiConstraintCollector.finisher()
on all the tuples of the originalBiConstraintStream
that belong to the group- Specified by:
groupBy
in interfaceBiConstraintStream<Solution_,A>
- Type Parameters:
GroupKeyA_
- the type of the first fact in the destinationQuadConstraintStream
's tupleGroupKeyB_
- the type of the second fact in the destinationQuadConstraintStream
's tupleResultContainerC_
- the mutable accumulation type (often hidden as an implementation detail)ResultC_
- the type of the third fact in the destinationQuadConstraintStream
's tupleResultContainerD_
- the mutable accumulation type (often hidden as an implementation detail)ResultD_
- the type of the fourth fact in the destinationQuadConstraintStream
's tuple- Parameters:
groupKeyAMapping
- never null, function to convert the original tuple into a first factgroupKeyBMapping
- never null, function to convert the original tuple into a second factcollectorC
- never null, the collector to perform the first grouping operation with SeeConstraintCollectors
for common operations, such ascount()
,sum()
and others.collectorD
- never null, the collector to perform the second grouping operation with SeeConstraintCollectors
for common operations, such ascount()
,sum()
and others.- Returns:
- never null
-
groupBy
public <GroupKeyA_,GroupKeyB_,GroupKeyC_> TriConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_> groupBy(BiFunction<A,B,GroupKeyA_> groupKeyAMapping, BiFunction<A,B,GroupKeyB_> groupKeyBMapping, BiFunction<A,B,GroupKeyC_> groupKeyCMapping)
Description copied from interface:BiConstraintStream
Convert theBiConstraintStream
to aTriConstraintStream
, consisting of unique tuples with three facts.The first fact is the return value of the first group key mapping function, applied on the incoming tuple. The second fact is the return value of the second group key mapping function, applied on all incoming tuples with the same first fact. The third fact is the return value of the third group key mapping function, applied on all incoming tuples with the same first fact.
- Specified by:
groupBy
in interfaceBiConstraintStream<Solution_,A>
- Type Parameters:
GroupKeyA_
- the type of the first fact in the destinationTriConstraintStream
's tupleGroupKeyB_
- the type of the second fact in the destinationTriConstraintStream
's tupleGroupKeyC_
- the type of the third fact in the destinationTriConstraintStream
's tuple- Parameters:
groupKeyAMapping
- never null, function to convert the original tuple into a first factgroupKeyBMapping
- never null, function to convert the original tuple into a second factgroupKeyCMapping
- never null, function to convert the original tuple into a third fact- Returns:
- never null
-
groupBy
public <GroupKeyA_,GroupKeyB_,GroupKeyC_,ResultContainerD_,ResultD_> QuadConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_,ResultD_> groupBy(BiFunction<A,B,GroupKeyA_> groupKeyAMapping, BiFunction<A,B,GroupKeyB_> groupKeyBMapping, BiFunction<A,B,GroupKeyC_> groupKeyCMapping, BiConstraintCollector<A,B,ResultContainerD_,ResultD_> collectorD)
Description copied from interface:BiConstraintStream
Combines the semantics ofBiConstraintStream.groupBy(BiFunction, BiFunction)
andBiConstraintStream.groupBy(BiConstraintCollector)
. That is, the first three facts in the tuple follow theBiConstraintStream.groupBy(BiFunction, BiFunction)
semantics. The final fact is the result of applying the firstBiConstraintCollector.finisher()
on all the tuples of the originalBiConstraintStream
that belong to the group.- Specified by:
groupBy
in interfaceBiConstraintStream<Solution_,A>
- Type Parameters:
GroupKeyA_
- the type of the first fact in the destinationQuadConstraintStream
's tupleGroupKeyB_
- the type of the second fact in the destinationQuadConstraintStream
's tupleGroupKeyC_
- the type of the third fact in the destinationQuadConstraintStream
's tupleResultContainerD_
- the mutable accumulation type (often hidden as an implementation detail)ResultD_
- the type of the fourth fact in the destinationQuadConstraintStream
's tuple- Parameters:
groupKeyAMapping
- never null, function to convert the original tuple into a first factgroupKeyBMapping
- never null, function to convert the original tuple into a second factgroupKeyCMapping
- never null, function to convert the original tuple into a third factcollectorD
- never null, the collector to perform the grouping operation with SeeConstraintCollectors
for common operations, such ascount()
,sum()
and others.- Returns:
- never null
-
groupBy
public <GroupKeyA_,GroupKeyB_,GroupKeyC_,GroupKeyD_> QuadConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_,GroupKeyD_> groupBy(BiFunction<A,B,GroupKeyA_> groupKeyAMapping, BiFunction<A,B,GroupKeyB_> groupKeyBMapping, BiFunction<A,B,GroupKeyC_> groupKeyCMapping, BiFunction<A,B,GroupKeyD_> groupKeyDMapping)
Description copied from interface:BiConstraintStream
Convert theBiConstraintStream
to aQuadConstraintStream
, consisting of unique tuples with four facts.The first fact is the return value of the first group key mapping function, applied on the incoming tuple. The second fact is the return value of the second group key mapping function, applied on all incoming tuples with the same first fact. The third fact is the return value of the third group key mapping function, applied on all incoming tuples with the same first fact. The fourth fact is the return value of the fourth group key mapping function, applied on all incoming tuples with the same first fact.
- Specified by:
groupBy
in interfaceBiConstraintStream<Solution_,A>
- Type Parameters:
GroupKeyA_
- the type of the first fact in the destinationQuadConstraintStream
's tupleGroupKeyB_
- the type of the second fact in the destinationQuadConstraintStream
's tupleGroupKeyC_
- the type of the third fact in the destinationQuadConstraintStream
's tupleGroupKeyD_
- the type of the fourth fact in the destinationQuadConstraintStream
's tuple- Parameters:
groupKeyAMapping
- never null, function to convert the original tuple into a first factgroupKeyBMapping
- never null, function to convert the original tuple into a second factgroupKeyCMapping
- never null, function to convert the original tuple into a third factgroupKeyDMapping
- never null, function to convert the original tuple into a fourth fact- Returns:
- never null
-
map
public <ResultA_> UniConstraintStream<ResultA_> map(BiFunction<A,B,ResultA_> mapping)
Description copied from interface:BiConstraintStream
As defined byUniConstraintStream.map(Function)
.- Specified by:
map
in interfaceBiConstraintStream<Solution_,A>
- Type Parameters:
ResultA_
- the type of the only fact in the resultingUniConstraintStream
's tuple- Parameters:
mapping
- never null, function to convert the original tuple into the new tuple- Returns:
- never null
-
flattenLast
public <ResultB_> BiConstraintStream<A,ResultB_> flattenLast(Function<B,Iterable<ResultB_>> mapping)
Description copied from interface:BiConstraintStream
Takes each tuple and applies a mapping on the last fact, which turns it intoIterable
. Returns a constraint stream consisting of tuples of the first fact and the contents of theIterable
one after another. In other words, it will replace the current tuple with new tuples, a cartesian product of A and the individual items from theIterable
.This may produce a stream with duplicate tuples. See
BiConstraintStream.distinct()
for details.In cases where the last fact is already
Iterable
, useFunction.identity()
as the argument.Simple example: assuming a constraint stream of
(PersonName, Person)
[(Ann, (name = Ann, roles = [USER, ADMIN])), (Beth, (name = Beth, roles = [USER])), (Cathy, (name = Cathy, roles = [ADMIN, AUDITOR]))]
, callingflattenLast(Person::getRoles)
on such stream will produce a stream of[(Ann, USER), (Ann, ADMIN), (Beth, USER), (Cathy, ADMIN), (Cathy, AUDITOR)]
.- Specified by:
flattenLast
in interfaceBiConstraintStream<Solution_,A>
- Type Parameters:
ResultB_
- the type of the last fact in the resulting tuples- Parameters:
mapping
- never null, function to convert the last fact in the original tuple intoIterable
- Returns:
- never null
-
impactScore
public final Constraint impactScore(String constraintPackage, String constraintName, Score<?> constraintWeight, ScoreImpactType impactType)
- Specified by:
impactScore
in classAbstractConstraintStream<Solution_>
-
impactScore
public final Constraint impactScore(String constraintPackage, String constraintName, Score<?> constraintWeight, ToIntBiFunction<A,B> matchWeigher, ScoreImpactType impactType)
- Specified by:
impactScore
in interfaceInnerBiConstraintStream<Solution_,A>
-
impactScoreLong
public final Constraint impactScoreLong(String constraintPackage, String constraintName, Score<?> constraintWeight, ToLongBiFunction<A,B> matchWeigher, ScoreImpactType impactType)
- Specified by:
impactScoreLong
in interfaceInnerBiConstraintStream<Solution_,A>
-
impactScoreBigDecimal
public final Constraint impactScoreBigDecimal(String constraintPackage, String constraintName, Score<?> constraintWeight, BiFunction<A,B,BigDecimal> matchWeigher, ScoreImpactType impactType)
- Specified by:
impactScoreBigDecimal
in interfaceInnerBiConstraintStream<Solution_,A>
-
impactScoreConfigurable
public final Constraint impactScoreConfigurable(String constraintPackage, String constraintName, ScoreImpactType impactType)
- Specified by:
impactScoreConfigurable
in classAbstractConstraintStream<Solution_>
-
impactScoreConfigurable
public final Constraint impactScoreConfigurable(String constraintPackage, String constraintName, ToIntBiFunction<A,B> matchWeigher, ScoreImpactType impactType)
- Specified by:
impactScoreConfigurable
in interfaceInnerBiConstraintStream<Solution_,A>
-
impactScoreConfigurableLong
public final Constraint impactScoreConfigurableLong(String constraintPackage, String constraintName, ToLongBiFunction<A,B> matchWeigher, ScoreImpactType impactType)
- Specified by:
impactScoreConfigurableLong
in interfaceInnerBiConstraintStream<Solution_,A>
-
impactScoreConfigurableBigDecimal
public final Constraint impactScoreConfigurableBigDecimal(String constraintPackage, String constraintName, BiFunction<A,B,BigDecimal> matchWeigher, ScoreImpactType impactType)
- Specified by:
impactScoreConfigurableBigDecimal
in interfaceInnerBiConstraintStream<Solution_,A>
-
createNodeChain
public BavetAbstractBiNode<A,B> createNodeChain(BavetNodeBuildPolicy<Solution_> buildPolicy, Score<?> constraintWeight, BavetAbstractBiNode<A,B> parentNode)
-
processNode
protected BavetAbstractBiNode<A,B> processNode(BavetNodeBuildPolicy<Solution_> buildPolicy, BavetAbstractBiNode<A,B> parentNode, BavetAbstractBiNode<A,B> node)
-
createChildNodeChains
protected void createChildNodeChains(BavetNodeBuildPolicy<Solution_> buildPolicy, Score<?> constraintWeight, BavetAbstractBiNode<A,B> node)
-
createNode
protected abstract BavetAbstractBiNode<A,B> createNode(BavetNodeBuildPolicy<Solution_> buildPolicy, Score<?> constraintWeight, BavetAbstractBiNode<A,B> parentNode)
-
-