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)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddChildStream(BavetAbstractBiConstraintStream<Solution_,A,B> childStream)protected voidcreateChildNodeChains(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 theBiPredicateand match ifBiPredicate.test(Object, Object)returns true.intgetCardinality()<GroupKey_>
UniConstraintStream<GroupKey_>groupBy(BiFunction<A,B,GroupKey_> groupKeyMapping)Convert theBiConstraintStreamto 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 theBiConstraintStreamto a differentBiConstraintStream, consisting of unique tuples.<GroupKeyA_,GroupKeyB_>
BiConstraintStream<GroupKeyA_,GroupKeyB_>groupBy(BiFunction<A,B,GroupKeyA_> groupKeyAMapping, BiFunction<A,B,GroupKeyB_> groupKeyBMapping)Convert theBiConstraintStreamto a differentBiConstraintStream, consisting of unique tuples.<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 @BiConstraintCollectorand converts them into a newUniConstraintStreamwhich only has a single tuple, the result of applyingBiConstraintCollector.<C> BiConstraintStream<A,B>ifExists(Class<C> otherClass, TriJoiner<A,B,C>... joiners)As defined byBiConstraintStream.ifExists(Class, TriJoiner).<C> BiConstraintStream<A,B>ifNotExists(Class<C> otherClass, TriJoiner<A,B,C>... joiners)As defined byBiConstraintStream.ifNotExists(Class, TriJoiner).ConstraintimpactScore(String constraintPackage, String constraintName, Score<?> constraintWeight, ToIntBiFunction<A,B> matchWeigher, ScoreImpactType impactType)ConstraintimpactScore(String constraintPackage, String constraintName, Score<?> constraintWeight, ScoreImpactType impactType)ConstraintimpactScoreBigDecimal(String constraintPackage, String constraintName, Score<?> constraintWeight, BiFunction<A,B,BigDecimal> matchWeigher, ScoreImpactType impactType)ConstraintimpactScoreConfigurable(String constraintPackage, String constraintName, ToIntBiFunction<A,B> matchWeigher, ScoreImpactType impactType)ConstraintimpactScoreConfigurable(String constraintPackage, String constraintName, ScoreImpactType impactType)ConstraintimpactScoreConfigurableBigDecimal(String constraintPackage, String constraintName, BiFunction<A,B,BigDecimal> matchWeigher, ScoreImpactType impactType)ConstraintimpactScoreConfigurableLong(String constraintPackage, String constraintName, ToLongBiFunction<A,B> matchWeigher, ScoreImpactType impactType)ConstraintimpactScoreLong(String constraintPackage, String constraintName, Score<?> constraintWeight, ToLongBiFunction<A,B> matchWeigher, ScoreImpactType impactType)<C> TriConstraintStream<A,B,C>join(UniConstraintStream<C> otherStream, TriJoiner<A,B,C> joiner)Create a newTriConstraintStreamfor every combination of [A, B] and C for which theTriJoineris true (for the properties it extracts from both facts).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, 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, ifNotExists, ifNotExists, ifNotExists, ifNotExists, impact, impactBigDecimal, impactConfigurable, impactConfigurableBigDecimal, impactConfigurableLong, impactLong, 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
impact, impactBigDecimal, impactConfigurable, impactConfigurableBigDecimal, impactConfigurableLong, impactLong, 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)
-
-
Method Detail
-
addChildStream
protected void addChildStream(BavetAbstractBiConstraintStream<Solution_,A,B> childStream)
-
getCardinality
public int getCardinality()
- Specified by:
getCardinalityin classAbstractConstraintStream<Solution_>
-
filter
public BavetAbstractBiConstraintStream<Solution_,A,B> filter(BiPredicate<A,B> predicate)
Description copied from interface:BiConstraintStreamExhaustively test each tuple of facts against theBiPredicateand match ifBiPredicate.test(Object, Object)returns true.Important: This is slower and less scalable than
UniConstraintStream.join(UniConstraintStream, BiJoiner)with a properBiJoinerpredicate (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:
filterin 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:BiConstraintStreamCreate a newTriConstraintStreamfor every combination of [A, B] and C for which theTriJoineris true (for the properties it extracts from both facts).Important: This is faster and more scalable than a
joinfollowed 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:
joinin 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
TriFunctionis true
-
ifExists
@SafeVarargs public final <C> BiConstraintStream<A,B> ifExists(Class<C> otherClass, TriJoiner<A,B,C>... joiners)
Description copied from interface:BiConstraintStreamAs 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
SafeVarargsannotation because it's an interface method. Therefore, there are overloaded methods with up to 4TriJoinerparameters.- Specified by:
ifExistsin 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
TriJoiners are true
-
ifNotExists
@SafeVarargs public final <C> BiConstraintStream<A,B> ifNotExists(Class<C> otherClass, TriJoiner<A,B,C>... joiners)
Description copied from interface:BiConstraintStreamAs 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
SafeVarargsannotation because it's an interface method. Therefore, there are overloaded methods with up to 4TriJoinerparameters.- Specified by:
ifNotExistsin 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
TriJoiners are true
-
groupBy
public <ResultContainer_,Result_> UniConstraintStream<Result_> groupBy(BiConstraintCollector<A,B,ResultContainer_,Result_> collector)
Description copied from interface:BiConstraintStreamRuns all tuples of the stream through a given @BiConstraintCollectorand converts them into a newUniConstraintStreamwhich only has a single tuple, the result of applyingBiConstraintCollector.- Specified by:
groupByin 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 SeeConstraintCollectorsfor 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:BiConstraintStreamConvert theBiConstraintStreamto 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:
groupByin 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_,ResultContainer_,Result_> BiConstraintStream<GroupKey_,Result_> groupBy(BiFunction<A,B,GroupKey_> groupKeyMapping, BiConstraintCollector<A,B,ResultContainer_,Result_> collector)
Description copied from interface:BiConstraintStreamConvert theBiConstraintStreamto 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 a given
BiConstraintCollectorapplied on all incoming tuples with the same first fact.- Specified by:
groupByin 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 SeeConstraintCollectorsfor 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:BiConstraintStreamConvert theBiConstraintStreamto 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:
groupByin 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:BiConstraintStreamCombines 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 originalUniConstraintStreamthat belong to the group.- Specified by:
groupByin 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 SeeConstraintCollectorsfor 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:BiConstraintStreamCombines 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 originalBiConstraintStreamthat belong to the group. The fourth fact is the result of applying the secondBiConstraintCollector.finisher()on all the tuples of the originalBiConstraintStreamthat belong to the group- Specified by:
groupByin 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 SeeConstraintCollectorsfor common operations, such ascount(),sum()and others.collectorD- never null, the collector to perform the second grouping operation with SeeConstraintCollectorsfor common operations, such ascount(),sum()and others.- Returns:
- never null
-
impactScore
public final Constraint impactScore(String constraintPackage, String constraintName, Score<?> constraintWeight, ScoreImpactType impactType)
- Specified by:
impactScorein classAbstractConstraintStream<Solution_>
-
impactScore
public final Constraint impactScore(String constraintPackage, String constraintName, Score<?> constraintWeight, ToIntBiFunction<A,B> matchWeigher, ScoreImpactType impactType)
- Specified by:
impactScorein interfaceInnerBiConstraintStream<Solution_,A>
-
impactScoreLong
public final Constraint impactScoreLong(String constraintPackage, String constraintName, Score<?> constraintWeight, ToLongBiFunction<A,B> matchWeigher, ScoreImpactType impactType)
- Specified by:
impactScoreLongin interfaceInnerBiConstraintStream<Solution_,A>
-
impactScoreBigDecimal
public final Constraint impactScoreBigDecimal(String constraintPackage, String constraintName, Score<?> constraintWeight, BiFunction<A,B,BigDecimal> matchWeigher, ScoreImpactType impactType)
- Specified by:
impactScoreBigDecimalin interfaceInnerBiConstraintStream<Solution_,A>
-
impactScoreConfigurable
public final Constraint impactScoreConfigurable(String constraintPackage, String constraintName, ScoreImpactType impactType)
- Specified by:
impactScoreConfigurablein classAbstractConstraintStream<Solution_>
-
impactScoreConfigurable
public final Constraint impactScoreConfigurable(String constraintPackage, String constraintName, ToIntBiFunction<A,B> matchWeigher, ScoreImpactType impactType)
- Specified by:
impactScoreConfigurablein interfaceInnerBiConstraintStream<Solution_,A>
-
impactScoreConfigurableLong
public final Constraint impactScoreConfigurableLong(String constraintPackage, String constraintName, ToLongBiFunction<A,B> matchWeigher, ScoreImpactType impactType)
- Specified by:
impactScoreConfigurableLongin interfaceInnerBiConstraintStream<Solution_,A>
-
impactScoreConfigurableBigDecimal
public final Constraint impactScoreConfigurableBigDecimal(String constraintPackage, String constraintName, BiFunction<A,B,BigDecimal> matchWeigher, ScoreImpactType impactType)
- Specified by:
impactScoreConfigurableBigDecimalin 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)
-
-