Class BavetAbstractUniConstraintStream<Solution_,A>
- 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.uni.BavetAbstractUniConstraintStream<Solution_,A>
-
- All Implemented Interfaces:
ConstraintStream,UniConstraintStream<A>,InnerUniConstraintStream<A>
- Direct Known Subclasses:
BavetFilterUniConstraintStream,BavetFromUniConstraintStream,BavetGroupBridgeUniConstraintStream,BavetJoinBridgeUniConstraintStream,BavetScoringUniConstraintStream
public abstract class BavetAbstractUniConstraintStream<Solution_,A> extends BavetAbstractConstraintStream<Solution_> implements InnerUniConstraintStream<A>
-
-
Field Summary
Fields Modifier and Type Field Description protected List<BavetAbstractUniConstraintStream<Solution_,A>>childStreamList-
Fields inherited from class org.optaplanner.core.impl.score.stream.bavet.common.BavetAbstractConstraintStream
constraintFactory
-
-
Constructor Summary
Constructors Constructor Description BavetAbstractUniConstraintStream(BavetConstraintFactory<Solution_> constraintFactory)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddChildStream(BavetAbstractUniConstraintStream<Solution_,A> childStream)protected voidcreateChildNodeChains(BavetNodeBuildPolicy<Solution_> buildPolicy, Score<?> constraintWeight, BavetAbstractUniNode<A> node)protected abstract BavetAbstractUniNode<A>createNode(BavetNodeBuildPolicy<Solution_> buildPolicy, Score<?> constraintWeight, BavetAbstractUniNode<A> parentNode)BavetAbstractUniNode<A>createNodeChain(BavetNodeBuildPolicy<Solution_> buildPolicy, Score<?> constraintWeight, BavetAbstractUniNode<A> parentNode)BavetAbstractUniConstraintStream<Solution_,A>filter(Predicate<A> predicate)Exhaustively test each fact against thePredicateand match ifPredicate.test(Object)returns true.<ResultA_> UniConstraintStream<ResultA_>flattenLast(Function<A,Iterable<ResultA_>> mapping)Takes each tuple and applies a mapping on it, which turns the tuple into aIterable.<GroupKey_>
UniConstraintStream<GroupKey_>groupBy(Function<A,GroupKey_> groupKeyMapping)Convert theUniConstraintStreamto a differentUniConstraintStream, 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(Function<A,GroupKey_> groupKeyMapping, UniConstraintCollector<A,ResultContainer_,Result_> collector)Convert theUniConstraintStreamto aBiConstraintStream, consisting of unique tuples with two facts.<GroupKey_,ResultContainerB_,ResultB_,ResultContainerC_,ResultC_>
TriConstraintStream<GroupKey_,ResultB_,ResultC_>groupBy(Function<A,GroupKey_> groupKeyMapping, UniConstraintCollector<A,ResultContainerB_,ResultB_> collectorB, UniConstraintCollector<A,ResultContainerC_,ResultC_> collectorC)Convert theUniConstraintStreamto aTriConstraintStream, consisting of unique tuples with three facts.<GroupKey_,ResultContainerB_,ResultB_,ResultContainerC_,ResultC_,ResultContainerD_,ResultD_>
QuadConstraintStream<GroupKey_,ResultB_,ResultC_,ResultD_>groupBy(Function<A,GroupKey_> groupKeyMapping, UniConstraintCollector<A,ResultContainerB_,ResultB_> collectorB, UniConstraintCollector<A,ResultContainerC_,ResultC_> collectorC, UniConstraintCollector<A,ResultContainerD_,ResultD_> collectorD)Convert theUniConstraintStreamto aQuadConstraintStream, consisting of unique tuples with four facts.<GroupKeyA_,GroupKeyB_>
BiConstraintStream<GroupKeyA_,GroupKeyB_>groupBy(Function<A,GroupKeyA_> groupKeyAMapping, Function<A,GroupKeyB_> groupKeyBMapping)Convert theUniConstraintStreamto aBiConstraintStream, consisting of unique tuples with two facts.<GroupKeyA_,GroupKeyB_,GroupKeyC_>
TriConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_>groupBy(Function<A,GroupKeyA_> groupKeyAMapping, Function<A,GroupKeyB_> groupKeyBMapping, Function<A,GroupKeyC_> groupKeyCMapping)Convert theUniConstraintStreamto aTriConstraintStream, consisting of unique tuples with three facts.<GroupKeyA_,GroupKeyB_,GroupKeyC_,GroupKeyD_>
QuadConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_,GroupKeyD_>groupBy(Function<A,GroupKeyA_> groupKeyAMapping, Function<A,GroupKeyB_> groupKeyBMapping, Function<A,GroupKeyC_> groupKeyCMapping, Function<A,GroupKeyD_> groupKeyDMapping)Convert theUniConstraintStreamto aQuadConstraintStream, consisting of unique tuples with four facts.<GroupKeyA_,GroupKeyB_,GroupKeyC_,ResultContainerD_,ResultD_>
QuadConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_,ResultD_>groupBy(Function<A,GroupKeyA_> groupKeyAMapping, Function<A,GroupKeyB_> groupKeyBMapping, Function<A,GroupKeyC_> groupKeyCMapping, UniConstraintCollector<A,ResultContainerD_,ResultD_> collectorD)Combines the semantics ofUniConstraintStream.groupBy(Function, Function)andUniConstraintStream.groupBy(UniConstraintCollector).<GroupKeyA_,GroupKeyB_,ResultContainer_,Result_>
TriConstraintStream<GroupKeyA_,GroupKeyB_,Result_>groupBy(Function<A,GroupKeyA_> groupKeyAMapping, Function<A,GroupKeyB_> groupKeyBMapping, UniConstraintCollector<A,ResultContainer_,Result_> collector)Combines the semantics ofUniConstraintStream.groupBy(Function, Function)andUniConstraintStream.groupBy(UniConstraintCollector).<GroupKeyA_,GroupKeyB_,ResultContainerC_,ResultC_,ResultContainerD_,ResultD_>
QuadConstraintStream<GroupKeyA_,GroupKeyB_,ResultC_,ResultD_>groupBy(Function<A,GroupKeyA_> groupKeyAMapping, Function<A,GroupKeyB_> groupKeyBMapping, UniConstraintCollector<A,ResultContainerC_,ResultC_> collectorC, UniConstraintCollector<A,ResultContainerD_,ResultD_> collectorD)Combines the semantics ofUniConstraintStream.groupBy(Function, Function)andUniConstraintStream.groupBy(UniConstraintCollector).<ResultContainer_,Result_>
UniConstraintStream<Result_>groupBy(UniConstraintCollector<A,ResultContainer_,Result_> collector)Convert theUniConstraintStreamto a differentUniConstraintStream, containing only a single tuple, the result of applyingUniConstraintCollector.<ResultContainerA_,ResultA_,ResultContainerB_,ResultB_>
BiConstraintStream<ResultA_,ResultB_>groupBy(UniConstraintCollector<A,ResultContainerA_,ResultA_> collectorA, UniConstraintCollector<A,ResultContainerB_,ResultB_> collectorB)Convert theUniConstraintStreamto aBiConstraintStream, containing only a single tuple, the result of applying twoUniConstraintCollectors.<ResultContainerA_,ResultA_,ResultContainerB_,ResultB_,ResultContainerC_,ResultC_>
TriConstraintStream<ResultA_,ResultB_,ResultC_>groupBy(UniConstraintCollector<A,ResultContainerA_,ResultA_> collectorA, UniConstraintCollector<A,ResultContainerB_,ResultB_> collectorB, UniConstraintCollector<A,ResultContainerC_,ResultC_> collectorC)Convert theUniConstraintStreamto aTriConstraintStream, containing only a single tuple, the result of applying threeUniConstraintCollectors.<ResultContainerA_,ResultA_,ResultContainerB_,ResultB_,ResultContainerC_,ResultC_,ResultContainerD_,ResultD_>
QuadConstraintStream<ResultA_,ResultB_,ResultC_,ResultD_>groupBy(UniConstraintCollector<A,ResultContainerA_,ResultA_> collectorA, UniConstraintCollector<A,ResultContainerB_,ResultB_> collectorB, UniConstraintCollector<A,ResultContainerC_,ResultC_> collectorC, UniConstraintCollector<A,ResultContainerD_,ResultD_> collectorD)Convert theUniConstraintStreamto aQuadConstraintStream, containing only a single tuple, the result of applying fourUniConstraintCollectors.<B> UniConstraintStream<A>ifExists(Class<B> otherClass, BiJoiner<A,B>... joiners)As defined byUniConstraintStream.ifExists(Class, BiJoiner).<B> UniConstraintStream<A>ifNotExists(Class<B> otherClass, BiJoiner<A,B>... joiners)As defined byUniConstraintStream.ifNotExists(Class, BiJoiner).ConstraintimpactScore(String constraintPackage, String constraintName, Score<?> constraintWeight, ToIntFunction<A> matchWeigher, ScoreImpactType impactType)ConstraintimpactScore(String constraintPackage, String constraintName, Score<?> constraintWeight, ScoreImpactType impactType)ConstraintimpactScoreBigDecimal(String constraintPackage, String constraintName, Score<?> constraintWeight, Function<A,BigDecimal> matchWeigher, ScoreImpactType impactType)ConstraintimpactScoreConfigurable(String constraintPackage, String constraintName, ToIntFunction<A> matchWeigher, ScoreImpactType impactType)ConstraintimpactScoreConfigurable(String constraintPackage, String constraintName, ScoreImpactType impactType)ConstraintimpactScoreConfigurableBigDecimal(String constraintPackage, String constraintName, Function<A,BigDecimal> matchWeigher, ScoreImpactType impactType)ConstraintimpactScoreConfigurableLong(String constraintPackage, String constraintName, ToLongFunction<A> matchWeigher, ScoreImpactType impactType)ConstraintimpactScoreLong(String constraintPackage, String constraintName, Score<?> constraintWeight, ToLongFunction<A> matchWeigher, ScoreImpactType impactType)<B> BiConstraintStream<A,B>join(UniConstraintStream<B> otherStream, BiJoiner<A,B> joiner)Create a newBiConstraintStreamfor every combination of A and B for which theBiJoineris true (for the properties it extracts from both facts).<ResultA_> UniConstraintStream<ResultA_>map(Function<A,ResultA_> mapping)Transforms the stream in such a way that tuples are remapped using the given function.protected BavetAbstractUniNode<A>processNode(BavetNodeBuildPolicy<Solution_> buildPolicy, BavetAbstractUniNode<A> parentNode, BavetAbstractUniNode<A> 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.uni.InnerUniConstraintStream
distinct, guaranteesDistinct, 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.uni.UniConstraintStream
ifExists, ifExists, ifExists, ifExists, ifExistsOther, ifExistsOther, ifExistsOther, ifExistsOther, ifExistsOther, ifExistsOther, ifNotExists, ifNotExists, ifNotExists, ifNotExists, ifNotExistsOther, ifNotExistsOther, ifNotExistsOther, ifNotExistsOther, ifNotExistsOther, ifNotExistsOther, impact, impactBigDecimal, impactConfigurable, impactConfigurableBigDecimal, impactConfigurableLong, impactLong, join, join, join, join, join, join, join, join, join, join, join, penalize, penalizeBigDecimal, penalizeConfigurable, penalizeConfigurableBigDecimal, penalizeConfigurableLong, penalizeLong, reward, rewardBigDecimal, rewardConfigurable, rewardConfigurableBigDecimal, rewardConfigurableLong, rewardLong
-
-
-
-
Field Detail
-
childStreamList
protected final List<BavetAbstractUniConstraintStream<Solution_,A>> childStreamList
-
-
Constructor Detail
-
BavetAbstractUniConstraintStream
public BavetAbstractUniConstraintStream(BavetConstraintFactory<Solution_> constraintFactory)
-
-
Method Detail
-
addChildStream
public void addChildStream(BavetAbstractUniConstraintStream<Solution_,A> childStream)
-
filter
public BavetAbstractUniConstraintStream<Solution_,A> filter(Predicate<A> predicate)
Description copied from interface:UniConstraintStreamExhaustively test each fact against thePredicateand match ifPredicate.test(Object)returns true.- Specified by:
filterin interfaceUniConstraintStream<Solution_>- Parameters:
predicate- never null- Returns:
- never null
-
join
public <B> BiConstraintStream<A,B> join(UniConstraintStream<B> otherStream, BiJoiner<A,B> joiner)
Description copied from interface:UniConstraintStreamCreate a newBiConstraintStreamfor every combination of A and B for which theBiJoineris 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 and B.- Specified by:
joinin interfaceUniConstraintStream<Solution_>- Type Parameters:
B- the type of the second matched fact- Parameters:
otherStream- never nulljoiner- never null- Returns:
- never null, a stream that matches every combination of A and B for which the
BiJoineris true
-
ifExists
@SafeVarargs public final <B> UniConstraintStream<A> ifExists(Class<B> otherClass, BiJoiner<A,B>... joiners)
Description copied from interface:UniConstraintStreamAs defined byUniConstraintStream.ifExists(Class, BiJoiner). 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 4BiJoinerparameters.- Specified by:
ifExistsin interfaceUniConstraintStream<Solution_>- Type Parameters:
B- the type of the second matched fact- Parameters:
otherClass- never nulljoiners- never null- Returns:
- never null, a stream that matches every A where B exists for which all the
BiJoiners are true
-
ifNotExists
@SafeVarargs public final <B> UniConstraintStream<A> ifNotExists(Class<B> otherClass, BiJoiner<A,B>... joiners)
Description copied from interface:UniConstraintStreamAs defined byUniConstraintStream.ifNotExists(Class, BiJoiner). 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 4BiJoinerparameters.- Specified by:
ifNotExistsin interfaceUniConstraintStream<Solution_>- Type Parameters:
B- the type of the second matched fact- Parameters:
otherClass- never nulljoiners- never null- Returns:
- never null, a stream that matches every A where B does not exist for which all the
BiJoiners are true
-
groupBy
public <ResultContainer_,Result_> UniConstraintStream<Result_> groupBy(UniConstraintCollector<A,ResultContainer_,Result_> collector)
Description copied from interface:UniConstraintStreamConvert theUniConstraintStreamto a differentUniConstraintStream, containing only a single tuple, the result of applyingUniConstraintCollector.- Specified by:
groupByin interfaceUniConstraintStream<Solution_>- 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 <ResultContainerA_,ResultA_,ResultContainerB_,ResultB_> BiConstraintStream<ResultA_,ResultB_> groupBy(UniConstraintCollector<A,ResultContainerA_,ResultA_> collectorA, UniConstraintCollector<A,ResultContainerB_,ResultB_> collectorB)
Description copied from interface:UniConstraintStreamConvert theUniConstraintStreamto aBiConstraintStream, containing only a single tuple, the result of applying twoUniConstraintCollectors.- Specified by:
groupByin interfaceUniConstraintStream<Solution_>- 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 SeeConstraintCollectorsfor common operations, such ascount(),sum()and others.collectorB- never null, the collector to perform the second grouping operation with SeeConstraintCollectorsfor common operations, such ascount(),sum()and others.- Returns:
- never null
-
groupBy
public <ResultContainerA_,ResultA_,ResultContainerB_,ResultB_,ResultContainerC_,ResultC_> TriConstraintStream<ResultA_,ResultB_,ResultC_> groupBy(UniConstraintCollector<A,ResultContainerA_,ResultA_> collectorA, UniConstraintCollector<A,ResultContainerB_,ResultB_> collectorB, UniConstraintCollector<A,ResultContainerC_,ResultC_> collectorC)
Description copied from interface:UniConstraintStreamConvert theUniConstraintStreamto aTriConstraintStream, containing only a single tuple, the result of applying threeUniConstraintCollectors.- Specified by:
groupByin interfaceUniConstraintStream<Solution_>- 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 SeeConstraintCollectorsfor common operations, such ascount(),sum()and others.collectorB- never null, the collector to perform the second grouping operation with SeeConstraintCollectorsfor common operations, such ascount(),sum()and others.collectorC- never null, the collector to perform the third grouping operation with SeeConstraintCollectorsfor 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(UniConstraintCollector<A,ResultContainerA_,ResultA_> collectorA, UniConstraintCollector<A,ResultContainerB_,ResultB_> collectorB, UniConstraintCollector<A,ResultContainerC_,ResultC_> collectorC, UniConstraintCollector<A,ResultContainerD_,ResultD_> collectorD)
Description copied from interface:UniConstraintStreamConvert theUniConstraintStreamto aQuadConstraintStream, containing only a single tuple, the result of applying fourUniConstraintCollectors.- Specified by:
groupByin interfaceUniConstraintStream<Solution_>- 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 SeeConstraintCollectorsfor common operations, such ascount(),sum()and others.collectorB- never null, the collector to perform the second grouping operation with SeeConstraintCollectorsfor common operations, such ascount(),sum()and others.collectorC- never null, the collector to perform the third grouping operation with SeeConstraintCollectorsfor common operations, such ascount(),sum()and others.collectorD- never null, the collector to perform the fourth grouping operation with SeeConstraintCollectorsfor common operations, such ascount(),sum()and others.- Returns:
- never null
-
groupBy
public <GroupKey_> UniConstraintStream<GroupKey_> groupBy(Function<A,GroupKey_> groupKeyMapping)
Description copied from interface:UniConstraintStreamConvert theUniConstraintStreamto a differentUniConstraintStream, 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 interfaceUniConstraintStream<Solution_>- 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(Function<A,GroupKey_> groupKeyMapping, UniConstraintCollector<A,ResultContainerB_,ResultB_> collectorB, UniConstraintCollector<A,ResultContainerC_,ResultC_> collectorC)
Description copied from interface:UniConstraintStreamConvert theUniConstraintStreamto 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
UniConstraintCollectorapplied on all incoming tuples with the same first fact.- Specified by:
groupByin interfaceUniConstraintStream<Solution_>- 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 SeeConstraintCollectorsfor common operations, such ascount(),sum()and others.collectorC- never null, the collector to perform the second grouping operation with SeeConstraintCollectorsfor 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(Function<A,GroupKey_> groupKeyMapping, UniConstraintCollector<A,ResultContainerB_,ResultB_> collectorB, UniConstraintCollector<A,ResultContainerC_,ResultC_> collectorC, UniConstraintCollector<A,ResultContainerD_,ResultD_> collectorD)
Description copied from interface:UniConstraintStreamConvert theUniConstraintStreamto 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
UniConstraintCollectorapplied on all incoming tuples with the same first fact.- Specified by:
groupByin interfaceUniConstraintStream<Solution_>- 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 SeeConstraintCollectorsfor common operations, such ascount(),sum()and others.collectorC- never null, the collector to perform the second grouping operation with SeeConstraintCollectorsfor common operations, such ascount(),sum()and others.collectorD- never null, the collector to perform the third grouping operation with SeeConstraintCollectorsfor common operations, such ascount(),sum()and others.- Returns:
- never null
-
groupBy
public <GroupKeyA_,GroupKeyB_> BiConstraintStream<GroupKeyA_,GroupKeyB_> groupBy(Function<A,GroupKeyA_> groupKeyAMapping, Function<A,GroupKeyB_> groupKeyBMapping)
Description copied from interface:UniConstraintStreamConvert theUniConstraintStreamto aBiConstraintStream, consisting of unique tuples with two 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.
- Specified by:
groupByin interfaceUniConstraintStream<Solution_>- 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 original tuple into a first factgroupKeyBMapping- never null, function to convert the original tuple into a second fact- Returns:
- never null
-
groupBy
public <GroupKey_,ResultContainer_,Result_> BiConstraintStream<GroupKey_,Result_> groupBy(Function<A,GroupKey_> groupKeyMapping, UniConstraintCollector<A,ResultContainer_,Result_> collector)
Description copied from interface:UniConstraintStreamConvert theUniConstraintStreamto aBiConstraintStream, consisting of unique tuples with two facts.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
UniConstraintCollectorapplied on all incoming tuples with the same first fact.- Specified by:
groupByin interfaceUniConstraintStream<Solution_>- 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_,ResultContainer_,Result_> TriConstraintStream<GroupKeyA_,GroupKeyB_,Result_> groupBy(Function<A,GroupKeyA_> groupKeyAMapping, Function<A,GroupKeyB_> groupKeyBMapping, UniConstraintCollector<A,ResultContainer_,Result_> collector)
Description copied from interface:UniConstraintStreamCombines the semantics ofUniConstraintStream.groupBy(Function, Function)andUniConstraintStream.groupBy(UniConstraintCollector). That is, the first and second facts in the tuple follow theUniConstraintStream.groupBy(Function, Function)semantics, and the third fact is the result of applyingUniConstraintCollector.finisher()on all the tuples of the originalUniConstraintStreamthat belong to the group.- Specified by:
groupByin interfaceUniConstraintStream<Solution_>- 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(Function<A,GroupKeyA_> groupKeyAMapping, Function<A,GroupKeyB_> groupKeyBMapping, UniConstraintCollector<A,ResultContainerC_,ResultC_> collectorC, UniConstraintCollector<A,ResultContainerD_,ResultD_> collectorD)
Description copied from interface:UniConstraintStreamCombines the semantics ofUniConstraintStream.groupBy(Function, Function)andUniConstraintStream.groupBy(UniConstraintCollector). That is, the first and second facts in the tuple follow theUniConstraintStream.groupBy(Function, Function)semantics. The third fact is the result of applying the firstUniConstraintCollector.finisher()on all the tuples of the originalUniConstraintStreamthat belong to the group. The fourth fact is the result of applying the secondUniConstraintCollector.finisher()on all the tuples of the originalUniConstraintStreamthat belong to the group- Specified by:
groupByin interfaceUniConstraintStream<Solution_>- 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
-
groupBy
public <GroupKeyA_,GroupKeyB_,GroupKeyC_> TriConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_> groupBy(Function<A,GroupKeyA_> groupKeyAMapping, Function<A,GroupKeyB_> groupKeyBMapping, Function<A,GroupKeyC_> groupKeyCMapping)
Description copied from interface:UniConstraintStreamConvert theUniConstraintStreamto 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:
groupByin interfaceUniConstraintStream<Solution_>- 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(Function<A,GroupKeyA_> groupKeyAMapping, Function<A,GroupKeyB_> groupKeyBMapping, Function<A,GroupKeyC_> groupKeyCMapping, UniConstraintCollector<A,ResultContainerD_,ResultD_> collectorD)
Description copied from interface:UniConstraintStreamCombines the semantics ofUniConstraintStream.groupBy(Function, Function)andUniConstraintStream.groupBy(UniConstraintCollector). That is, the first three facts in the tuple follow theUniConstraintStream.groupBy(Function, Function)semantics. The final fact is the result of applying the firstUniConstraintCollector.finisher()on all the tuples of the originalUniConstraintStreamthat belong to the group.- Specified by:
groupByin interfaceUniConstraintStream<Solution_>- 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 SeeConstraintCollectorsfor common operations, such ascount(),sum()and others.- Returns:
- never null
-
groupBy
public <GroupKeyA_,GroupKeyB_,GroupKeyC_,GroupKeyD_> QuadConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_,GroupKeyD_> groupBy(Function<A,GroupKeyA_> groupKeyAMapping, Function<A,GroupKeyB_> groupKeyBMapping, Function<A,GroupKeyC_> groupKeyCMapping, Function<A,GroupKeyD_> groupKeyDMapping)
Description copied from interface:UniConstraintStreamConvert theUniConstraintStreamto 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:
groupByin interfaceUniConstraintStream<Solution_>- 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- * callingmap(Person::getAge)on such stream will produce a stream ofIntegers *[20, 25, 30],groupKeyBMapping- 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(Function<A,ResultA_> mapping)
Description copied from interface:UniConstraintStreamTransforms the stream in such a way that tuples are remapped using the given function. This may produce a stream with duplicate tuples. SeeUniConstraintStream.distinct()for details. There are several recommendations for implementing the mapping function:- Purity. The mapping function should only depend on its input. That is, given the same input, it always returns the same output.
- Bijectivity.
No two input tuples should map to the same output tuple,
or to tuples that are
equal. Not following this recommendation creates a constraint stream with duplicate tuples, and may force you to useUniConstraintStream.distinct()later, which comes with a performance cost. - Immutable data carriers.
The objects returned by the mapping function should be identified by their contents and nothing else.
If two of them have contents which
equal, then they should likewiseequaland preferably be the same instance. The objects returned by the mapping function should also be immutable, meaning their contents should not be allowed to change.
Simple example: assuming a constraint stream of tuples of
Persons[Ann(age = 20), Beth(age = 25), Cathy(age = 30)], callingmap(Person::getAge)on such stream will produce a stream ofIntegers[20, 25, 30],Example with a non-bijective mapping function: assuming a constraint stream of tuples of
Persons[Ann(age = 20), Beth(age = 25), Cathy(age = 30), David(age = 30), Eric(age = 20)], callingmap(Person::getAge)on such stream will produce a stream ofIntegers[20, 25, 30, 30, 20].- Specified by:
mapin interfaceUniConstraintStream<Solution_>- 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 <ResultA_> UniConstraintStream<ResultA_> flattenLast(Function<A,Iterable<ResultA_>> mapping)
Description copied from interface:UniConstraintStreamTakes each tuple and applies a mapping on it, which turns the tuple into aIterable. Returns a constraint stream consisting of contents of those iterables. This may produce a stream with duplicate tuples. SeeUniConstraintStream.distinct()for details.In cases where the original tuple is already an
Iterable, useFunction.identity()as the argument.Simple example: assuming a constraint stream of tuples of
Persons[Ann(roles = [USER, ADMIN]]), Beth(roles = [USER]), Cathy(roles = [ADMIN, AUDITOR])], callingflattenLast(Person::getRoles)on such stream will produce a stream of[USER, ADMIN, USER, ADMIN, AUDITOR].- Specified by:
flattenLastin interfaceUniConstraintStream<Solution_>- Type Parameters:
ResultA_- the type of facts in the resulting tuples- Parameters:
mapping- never null, function to convert the original tuple intoIterable- 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, ToIntFunction<A> matchWeigher, ScoreImpactType impactType)
- Specified by:
impactScorein interfaceInnerUniConstraintStream<Solution_>
-
impactScoreLong
public final Constraint impactScoreLong(String constraintPackage, String constraintName, Score<?> constraintWeight, ToLongFunction<A> matchWeigher, ScoreImpactType impactType)
- Specified by:
impactScoreLongin interfaceInnerUniConstraintStream<Solution_>
-
impactScoreBigDecimal
public final Constraint impactScoreBigDecimal(String constraintPackage, String constraintName, Score<?> constraintWeight, Function<A,BigDecimal> matchWeigher, ScoreImpactType impactType)
- Specified by:
impactScoreBigDecimalin interfaceInnerUniConstraintStream<Solution_>
-
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, ToIntFunction<A> matchWeigher, ScoreImpactType impactType)
- Specified by:
impactScoreConfigurablein interfaceInnerUniConstraintStream<Solution_>
-
impactScoreConfigurableLong
public final Constraint impactScoreConfigurableLong(String constraintPackage, String constraintName, ToLongFunction<A> matchWeigher, ScoreImpactType impactType)
- Specified by:
impactScoreConfigurableLongin interfaceInnerUniConstraintStream<Solution_>
-
impactScoreConfigurableBigDecimal
public final Constraint impactScoreConfigurableBigDecimal(String constraintPackage, String constraintName, Function<A,BigDecimal> matchWeigher, ScoreImpactType impactType)
- Specified by:
impactScoreConfigurableBigDecimalin interfaceInnerUniConstraintStream<Solution_>
-
createNodeChain
public BavetAbstractUniNode<A> createNodeChain(BavetNodeBuildPolicy<Solution_> buildPolicy, Score<?> constraintWeight, BavetAbstractUniNode<A> parentNode)
-
processNode
protected BavetAbstractUniNode<A> processNode(BavetNodeBuildPolicy<Solution_> buildPolicy, BavetAbstractUniNode<A> parentNode, BavetAbstractUniNode<A> node)
-
createChildNodeChains
protected void createChildNodeChains(BavetNodeBuildPolicy<Solution_> buildPolicy, Score<?> constraintWeight, BavetAbstractUniNode<A> node)
-
createNode
protected abstract BavetAbstractUniNode<A> createNode(BavetNodeBuildPolicy<Solution_> buildPolicy, Score<?> constraintWeight, BavetAbstractUniNode<A> parentNode)
-
-