Class BavetAbstractTriConstraintStream<Solution_,A,B,C>
- 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.tri.BavetAbstractTriConstraintStream<Solution_,A,B,C>
-
- All Implemented Interfaces:
ConstraintStream,TriConstraintStream<A,B,C>,InnerTriConstraintStream<A,B,C>
- Direct Known Subclasses:
BavetFilterTriConstraintStream,BavetJoinTriConstraintStream,BavetScoringTriConstraintStream
public abstract class BavetAbstractTriConstraintStream<Solution_,A,B,C> extends BavetAbstractConstraintStream<Solution_> implements InnerTriConstraintStream<A,B,C>
-
-
Field Summary
Fields Modifier and Type Field Description protected List<BavetAbstractTriConstraintStream<Solution_,A,B,C>>childStreamList-
Fields inherited from class org.optaplanner.core.impl.score.stream.bavet.common.BavetAbstractConstraintStream
constraintFactory
-
-
Constructor Summary
Constructors Constructor Description BavetAbstractTriConstraintStream(BavetConstraintFactory<Solution_> constraintFactory)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddChildStream(BavetAbstractTriConstraintStream<Solution_,A,B,C> childStream)protected voidcreateChildNodeChains(BavetNodeBuildPolicy<Solution_> buildPolicy, Score<?> constraintWeight, BavetAbstractTriNode<A,B,C> node)protected abstract BavetAbstractTriNode<A,B,C>createNode(BavetNodeBuildPolicy<Solution_> buildPolicy, Score<?> constraintWeight, BavetAbstractTriNode<A,B,C> parentNode)BavetAbstractTriNode<A,B,C>createNodeChain(BavetNodeBuildPolicy<Solution_> buildPolicy, Score<?> constraintWeight, BavetAbstractTriNode<A,B,C> parentNode)BavetAbstractTriConstraintStream<Solution_,A,B,C>filter(TriPredicate<A,B,C> predicate)Exhaustively test each tuple of facts against theTriPredicateand match ifTriPredicate.test(Object, Object, Object)returns true.intgetCardinality()<GroupKey_>
UniConstraintStream<GroupKey_>groupBy(TriFunction<A,B,C,GroupKey_> groupKeyMapping)Convert theTriConstraintStreamto 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(TriFunction<A,B,C,GroupKey_> groupKeyMapping, TriConstraintCollector<A,B,C,ResultContainer_,Result_> collector)Convert theTriConstraintStreamto aBiConstraintStream, consisting of unique tuples.<GroupKeyA_,GroupKeyB_>
BiConstraintStream<GroupKeyA_,GroupKeyB_>groupBy(TriFunction<A,B,C,GroupKeyA_> groupKeyAMapping, TriFunction<A,B,C,GroupKeyB_> groupKeyBMapping)Convert theTriConstraintStreamto aBiConstraintStream, consisting of unique tuples.<GroupKeyA_,GroupKeyB_,ResultContainer_,Result_>
TriConstraintStream<GroupKeyA_,GroupKeyB_,Result_>groupBy(TriFunction<A,B,C,GroupKeyA_> groupKeyAMapping, TriFunction<A,B,C,GroupKeyB_> groupKeyBMapping, TriConstraintCollector<A,B,C,ResultContainer_,Result_> collector)Combines the semantics ofTriConstraintStream.groupBy(TriFunction, TriFunction)andTriConstraintStream.groupBy(TriConstraintCollector).<GroupKeyA_,GroupKeyB_,ResultContainerC_,ResultC_,ResultContainerD_,ResultD_>
QuadConstraintStream<GroupKeyA_,GroupKeyB_,ResultC_,ResultD_>groupBy(TriFunction<A,B,C,GroupKeyA_> groupKeyAMapping, TriFunction<A,B,C,GroupKeyB_> groupKeyBMapping, TriConstraintCollector<A,B,C,ResultContainerC_,ResultC_> collectorC, TriConstraintCollector<A,B,C,ResultContainerD_,ResultD_> collectorD)Combines the semantics ofTriConstraintStream.groupBy(TriFunction, TriFunction)andTriConstraintStream.groupBy(TriConstraintCollector).<ResultContainer_,Result_>
UniConstraintStream<Result_>groupBy(TriConstraintCollector<A,B,C,ResultContainer_,Result_> collector)Convert theTriConstraintStreamto aUniConstraintStream, containing only a single tuple, the result of applyingTriConstraintCollector.<D> TriConstraintStream<A,B,C>ifExists(Class<D> otherClass, QuadJoiner<A,B,C,D>... joiners)As defined byTriConstraintStream.ifExists(Class, QuadJoiner).<D> TriConstraintStream<A,B,C>ifNotExists(Class<D> otherClass, QuadJoiner<A,B,C,D>... joiners)As defined byTriConstraintStream.ifNotExists(Class, QuadJoiner).ConstraintimpactScore(String constraintPackage, String constraintName, Score<?> constraintWeight, ToIntTriFunction<A,B,C> matchWeigher, ScoreImpactType impactType)ConstraintimpactScore(String constraintPackage, String constraintName, Score<?> constraintWeight, ScoreImpactType impactType)ConstraintimpactScoreBigDecimal(String constraintPackage, String constraintName, Score<?> constraintWeight, TriFunction<A,B,C,BigDecimal> matchWeigher, ScoreImpactType impactType)ConstraintimpactScoreConfigurable(String constraintPackage, String constraintName, ToIntTriFunction<A,B,C> matchWeigher, ScoreImpactType impactType)ConstraintimpactScoreConfigurable(String constraintPackage, String constraintName, ScoreImpactType impactType)ConstraintimpactScoreConfigurableBigDecimal(String constraintPackage, String constraintName, TriFunction<A,B,C,BigDecimal> matchWeigher, ScoreImpactType impactType)ConstraintimpactScoreConfigurableLong(String constraintPackage, String constraintName, ToLongTriFunction<A,B,C> matchWeigher, ScoreImpactType impactType)ConstraintimpactScoreLong(String constraintPackage, String constraintName, Score<?> constraintWeight, ToLongTriFunction<A,B,C> matchWeigher, ScoreImpactType impactType)<D> QuadConstraintStream<A,B,C,D>join(UniConstraintStream<D> otherStream, QuadJoiner<A,B,C,D> joiner)Create a newQuadConstraintStreamfor every combination of [A, B] and C for which theQuadJoineris true (for the properties it extracts from all facts).protected BavetAbstractTriNode<A,B,C>processNode(BavetNodeBuildPolicy<Solution_> buildPolicy, BavetAbstractTriNode<A,B,C> parentNode, BavetAbstractTriNode<A,B,C> 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.ConstraintStream
getConstraintFactory, impact, impact, penalize, penalize, penalizeConfigurable, penalizeConfigurable, reward, reward, rewardConfigurable, rewardConfigurable
-
Methods inherited from interface org.optaplanner.core.impl.score.stream.tri.InnerTriConstraintStream
impact, impactBigDecimal, impactConfigurable, impactConfigurableBigDecimal, impactConfigurableLong, impactLong, penalize, penalizeBigDecimal, penalizeConfigurable, penalizeConfigurableBigDecimal, penalizeConfigurableLong, penalizeLong, reward, rewardBigDecimal, rewardConfigurable, rewardConfigurableBigDecimal, rewardConfigurableLong, rewardLong
-
Methods inherited from interface org.optaplanner.core.api.score.stream.tri.TriConstraintStream
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
-
-
-
-
Constructor Detail
-
BavetAbstractTriConstraintStream
public BavetAbstractTriConstraintStream(BavetConstraintFactory<Solution_> constraintFactory)
-
-
Method Detail
-
addChildStream
protected void addChildStream(BavetAbstractTriConstraintStream<Solution_,A,B,C> childStream)
-
getCardinality
public int getCardinality()
- Specified by:
getCardinalityin classAbstractConstraintStream<Solution_>
-
filter
public BavetAbstractTriConstraintStream<Solution_,A,B,C> filter(TriPredicate<A,B,C> predicate)
Description copied from interface:TriConstraintStreamExhaustively test each tuple of facts against theTriPredicateand match ifTriPredicate.test(Object, Object, Object)returns true.Important: This is slower and less scalable than
BiConstraintStream.join(UniConstraintStream, TriJoiner)with a properTriJoinerpredicate (such asJoiners.equal(BiFunction, Function), because the latter applies hashing and/or indexing, so it doesn't create every combination just to filter it out.- Specified by:
filterin interfaceTriConstraintStream<Solution_,A,B>- Parameters:
predicate- never null- Returns:
- never null
-
join
public <D> QuadConstraintStream<A,B,C,D> join(UniConstraintStream<D> otherStream, QuadJoiner<A,B,C,D> joiner)
Description copied from interface:TriConstraintStreamCreate a newQuadConstraintStreamfor every combination of [A, B] and C for which theQuadJoineris true (for the properties it extracts from all 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, C] and D.- Specified by:
joinin interfaceTriConstraintStream<Solution_,A,B>- Type Parameters:
D- the type of the fourth matched fact- Parameters:
otherStream- never nulljoiner- never null- Returns:
- never null, a stream that matches every combination of [A, B, C] and D for which the
QuadJoineris true
-
ifExists
@SafeVarargs public final <D> TriConstraintStream<A,B,C> ifExists(Class<D> otherClass, QuadJoiner<A,B,C,D>... joiners)
Description copied from interface:TriConstraintStreamAs defined byTriConstraintStream.ifExists(Class, QuadJoiner). 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 4QuadJoinerparameters.- Specified by:
ifExistsin interfaceTriConstraintStream<Solution_,A,B>- Type Parameters:
D- the type of the fourth matched fact- Parameters:
otherClass- never nulljoiners- never null- Returns:
- never null, a stream that matches every tuple of A, B and C where D exists for which the
QuadJoiners are true
-
ifNotExists
@SafeVarargs public final <D> TriConstraintStream<A,B,C> ifNotExists(Class<D> otherClass, QuadJoiner<A,B,C,D>... joiners)
Description copied from interface:TriConstraintStreamAs defined byTriConstraintStream.ifNotExists(Class, QuadJoiner). 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 4QuadJoinerparameters.- Specified by:
ifNotExistsin interfaceTriConstraintStream<Solution_,A,B>- Type Parameters:
D- the type of the fourth matched fact- Parameters:
otherClass- never nulljoiners- never null- Returns:
- never null, a stream that matches every tuple of A, B and C where D does not exist for which the
QuadJoiners are true
-
groupBy
public <ResultContainer_,Result_> UniConstraintStream<Result_> groupBy(TriConstraintCollector<A,B,C,ResultContainer_,Result_> collector)
Description copied from interface:TriConstraintStreamConvert theTriConstraintStreamto aUniConstraintStream, containing only a single tuple, the result of applyingTriConstraintCollector.- Specified by:
groupByin interfaceTriConstraintStream<Solution_,A,B>- 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(TriFunction<A,B,C,GroupKey_> groupKeyMapping)
Description copied from interface:TriConstraintStreamConvert theTriConstraintStreamto 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 interfaceTriConstraintStream<Solution_,A,B>- 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(TriFunction<A,B,C,GroupKey_> groupKeyMapping, TriConstraintCollector<A,B,C,ResultContainer_,Result_> collector)
Description copied from interface:TriConstraintStreamConvert theTriConstraintStreamto aBiConstraintStream, 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
TriConstraintCollectorapplied on all incoming tuples with the same first fact.- Specified by:
groupByin interfaceTriConstraintStream<Solution_,A,B>- 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(TriFunction<A,B,C,GroupKeyA_> groupKeyAMapping, TriFunction<A,B,C,GroupKeyB_> groupKeyBMapping)
Description copied from interface:TriConstraintStreamConvert theTriConstraintStreamto aBiConstraintStream, 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 interfaceTriConstraintStream<Solution_,A,B>- 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(TriFunction<A,B,C,GroupKeyA_> groupKeyAMapping, TriFunction<A,B,C,GroupKeyB_> groupKeyBMapping, TriConstraintCollector<A,B,C,ResultContainer_,Result_> collector)
Description copied from interface:TriConstraintStreamCombines the semantics ofTriConstraintStream.groupBy(TriFunction, TriFunction)andTriConstraintStream.groupBy(TriConstraintCollector). That is, the first and second facts in the tuple follow theTriConstraintStream.groupBy(TriFunction, TriFunction)semantics, and the third fact is the result of applyingTriConstraintCollector.finisher()on all the tuples of the originalUniConstraintStreamthat belong to the group.- Specified by:
groupByin interfaceTriConstraintStream<Solution_,A,B>- 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(TriFunction<A,B,C,GroupKeyA_> groupKeyAMapping, TriFunction<A,B,C,GroupKeyB_> groupKeyBMapping, TriConstraintCollector<A,B,C,ResultContainerC_,ResultC_> collectorC, TriConstraintCollector<A,B,C,ResultContainerD_,ResultD_> collectorD)
Description copied from interface:TriConstraintStreamCombines the semantics ofTriConstraintStream.groupBy(TriFunction, TriFunction)andTriConstraintStream.groupBy(TriConstraintCollector). That is, the first and second facts in the tuple follow theTriConstraintStream.groupBy(TriFunction, TriFunction)semantics. The third fact is the result of applying the firstTriConstraintCollector.finisher()on all the tuples of the originalTriConstraintStreamthat belong to the group. The fourth fact is the result of applying the secondTriConstraintCollector.finisher()on all the tuples of the originalTriConstraintStreamthat belong to the group- Specified by:
groupByin interfaceTriConstraintStream<Solution_,A,B>- 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, ToIntTriFunction<A,B,C> matchWeigher, ScoreImpactType impactType)
- Specified by:
impactScorein interfaceInnerTriConstraintStream<Solution_,A,B>
-
impactScoreLong
public final Constraint impactScoreLong(String constraintPackage, String constraintName, Score<?> constraintWeight, ToLongTriFunction<A,B,C> matchWeigher, ScoreImpactType impactType)
- Specified by:
impactScoreLongin interfaceInnerTriConstraintStream<Solution_,A,B>
-
impactScoreBigDecimal
public final Constraint impactScoreBigDecimal(String constraintPackage, String constraintName, Score<?> constraintWeight, TriFunction<A,B,C,BigDecimal> matchWeigher, ScoreImpactType impactType)
- Specified by:
impactScoreBigDecimalin interfaceInnerTriConstraintStream<Solution_,A,B>
-
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, ToIntTriFunction<A,B,C> matchWeigher, ScoreImpactType impactType)
- Specified by:
impactScoreConfigurablein interfaceInnerTriConstraintStream<Solution_,A,B>
-
impactScoreConfigurableLong
public final Constraint impactScoreConfigurableLong(String constraintPackage, String constraintName, ToLongTriFunction<A,B,C> matchWeigher, ScoreImpactType impactType)
- Specified by:
impactScoreConfigurableLongin interfaceInnerTriConstraintStream<Solution_,A,B>
-
impactScoreConfigurableBigDecimal
public final Constraint impactScoreConfigurableBigDecimal(String constraintPackage, String constraintName, TriFunction<A,B,C,BigDecimal> matchWeigher, ScoreImpactType impactType)
- Specified by:
impactScoreConfigurableBigDecimalin interfaceInnerTriConstraintStream<Solution_,A,B>
-
createNodeChain
public BavetAbstractTriNode<A,B,C> createNodeChain(BavetNodeBuildPolicy<Solution_> buildPolicy, Score<?> constraintWeight, BavetAbstractTriNode<A,B,C> parentNode)
-
processNode
protected BavetAbstractTriNode<A,B,C> processNode(BavetNodeBuildPolicy<Solution_> buildPolicy, BavetAbstractTriNode<A,B,C> parentNode, BavetAbstractTriNode<A,B,C> node)
-
createChildNodeChains
protected void createChildNodeChains(BavetNodeBuildPolicy<Solution_> buildPolicy, Score<?> constraintWeight, BavetAbstractTriNode<A,B,C> node)
-
createNode
protected abstract BavetAbstractTriNode<A,B,C> createNode(BavetNodeBuildPolicy<Solution_> buildPolicy, Score<?> constraintWeight, BavetAbstractTriNode<A,B,C> parentNode)
-
-