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, RetrievalSemantics retrievalSemantics)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addChildStream(BavetAbstractUniConstraintStream<Solution_,A> childStream)
protected void
createChildNodeChains(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 thePredicate
and 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 theUniConstraintStream
to 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 theUniConstraintStream
to 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 theUniConstraintStream
to 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 theUniConstraintStream
to aQuadConstraintStream
, consisting of unique tuples with four facts.<GroupKeyA_,GroupKeyB_>
BiConstraintStream<GroupKeyA_,GroupKeyB_>groupBy(Function<A,GroupKeyA_> groupKeyAMapping, Function<A,GroupKeyB_> groupKeyBMapping)
Convert theUniConstraintStream
to 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 theUniConstraintStream
to 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 theUniConstraintStream
to 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 theUniConstraintStream
to 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 theUniConstraintStream
to aBiConstraintStream
, containing only a single tuple, the result of applying twoUniConstraintCollector
s.<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 theUniConstraintStream
to aTriConstraintStream
, containing only a single tuple, the result of applying threeUniConstraintCollector
s.<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 theUniConstraintStream
to aQuadConstraintStream
, containing only a single tuple, the result of applying fourUniConstraintCollector
s.<B> UniConstraintStream<A>
ifExists(Class<B> otherClass, BiJoiner<A,B>... joiners)
As defined byUniConstraintStream.ifExists(Class, BiJoiner)
.<B> UniConstraintStream<A>
ifExistsIncludingNullVars(Class<B> otherClass, BiJoiner<A,B>... joiners)
<B> UniConstraintStream<A>
ifNotExists(Class<B> otherClass, BiJoiner<A,B>... joiners)
As defined byUniConstraintStream.ifNotExists(Class, BiJoiner)
.<B> UniConstraintStream<A>
ifNotExistsIncludingNullVars(Class<B> otherClass, BiJoiner<A,B>... joiners)
Constraint
impactScore(String constraintPackage, String constraintName, Score<?> constraintWeight, ToIntFunction<A> matchWeigher, ScoreImpactType impactType)
Constraint
impactScore(String constraintPackage, String constraintName, Score<?> constraintWeight, ScoreImpactType impactType)
Constraint
impactScoreBigDecimal(String constraintPackage, String constraintName, Score<?> constraintWeight, Function<A,BigDecimal> matchWeigher, ScoreImpactType impactType)
Constraint
impactScoreConfigurable(String constraintPackage, String constraintName, ToIntFunction<A> matchWeigher, ScoreImpactType impactType)
Constraint
impactScoreConfigurable(String constraintPackage, String constraintName, ScoreImpactType impactType)
Constraint
impactScoreConfigurableBigDecimal(String constraintPackage, String constraintName, Function<A,BigDecimal> matchWeigher, ScoreImpactType impactType)
Constraint
impactScoreConfigurableLong(String constraintPackage, String constraintName, ToLongFunction<A> matchWeigher, ScoreImpactType impactType)
Constraint
impactScoreLong(String constraintPackage, String constraintName, Score<?> constraintWeight, ToLongFunction<A> matchWeigher, ScoreImpactType impactType)
<B> BiConstraintStream<A,B>
join(Class<B> otherClass, BiJoiner<A,B>... joiners)
As defined byUniConstraintStream.join(Class, BiJoiner)
.<B> BiConstraintStream<A,B>
join(UniConstraintStream<B> otherStream, BiJoiner<A,B> joiner)
Create a newBiConstraintStream
for every combination of A and B for which theBiJoiner
is 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, 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.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, join, 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, ifExistsIncludingNullVars, ifExistsIncludingNullVars, ifExistsIncludingNullVars, ifExistsIncludingNullVars, ifExistsOther, ifExistsOther, ifExistsOther, ifExistsOther, ifExistsOther, ifExistsOther, ifExistsOtherIncludingNullVars, ifExistsOtherIncludingNullVars, ifExistsOtherIncludingNullVars, ifExistsOtherIncludingNullVars, ifExistsOtherIncludingNullVars, ifExistsOtherIncludingNullVars, ifNotExists, ifNotExists, ifNotExists, ifNotExists, ifNotExistsIncludingNullVars, ifNotExistsIncludingNullVars, ifNotExistsIncludingNullVars, ifNotExistsIncludingNullVars, ifNotExistsOther, ifNotExistsOther, ifNotExistsOther, ifNotExistsOther, ifNotExistsOther, ifNotExistsOther, ifNotExistsOtherIncludingNullVars, ifNotExistsOtherIncludingNullVars, ifNotExistsOtherIncludingNullVars, ifNotExistsOtherIncludingNullVars, ifNotExistsOtherIncludingNullVars, ifNotExistsOtherIncludingNullVars, 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
-
-
-
-
Field Detail
-
childStreamList
protected final List<BavetAbstractUniConstraintStream<Solution_,A>> childStreamList
-
-
Constructor Detail
-
BavetAbstractUniConstraintStream
public BavetAbstractUniConstraintStream(BavetConstraintFactory<Solution_> constraintFactory, RetrievalSemantics retrievalSemantics)
-
-
Method Detail
-
addChildStream
public void addChildStream(BavetAbstractUniConstraintStream<Solution_,A> childStream)
-
filter
public BavetAbstractUniConstraintStream<Solution_,A> filter(Predicate<A> predicate)
Description copied from interface:UniConstraintStream
Exhaustively test each fact against thePredicate
and match ifPredicate.test(Object)
returns true.- Specified by:
filter
in 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:UniConstraintStream
Create a newBiConstraintStream
for every combination of A and B for which theBiJoiner
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 and B.- Specified by:
join
in 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
BiJoiner
is true
-
join
public <B> BiConstraintStream<A,B> join(Class<B> otherClass, BiJoiner<A,B>... joiners)
Description copied from interface:UniConstraintStream
As defined byUniConstraintStream.join(Class, BiJoiner)
. For performance reasons, the 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 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 combination of A and B for which all the
joiners
are true
-
ifExists
@SafeVarargs public final <B> UniConstraintStream<A> ifExists(Class<B> otherClass, BiJoiner<A,B>... joiners)
Description copied from interface:UniConstraintStream
As 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
SafeVarargs
annotation because it's an interface method. Therefore, there are overloaded methods with up to 4BiJoiner
parameters.- Specified by:
ifExists
in 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
BiJoiner
s are true
-
ifExistsIncludingNullVars
@SafeVarargs public final <B> UniConstraintStream<A> ifExistsIncludingNullVars(Class<B> otherClass, BiJoiner<A,B>... joiners)
Description copied from interface:UniConstraintStream
As defined byUniConstraintStream.ifExistsIncludingNullVars(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
SafeVarargs
annotation because it's an interface method. Therefore, there are overloaded methods with up to 4BiJoiner
parameters.- Specified by:
ifExistsIncludingNullVars
in 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
BiJoiner
s are true
-
ifNotExists
@SafeVarargs public final <B> UniConstraintStream<A> ifNotExists(Class<B> otherClass, BiJoiner<A,B>... joiners)
Description copied from interface:UniConstraintStream
As 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
SafeVarargs
annotation because it's an interface method. Therefore, there are overloaded methods with up to 4BiJoiner
parameters.- Specified by:
ifNotExists
in 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
BiJoiner
s are true
-
ifNotExistsIncludingNullVars
@SafeVarargs public final <B> UniConstraintStream<A> ifNotExistsIncludingNullVars(Class<B> otherClass, BiJoiner<A,B>... joiners)
Description copied from interface:UniConstraintStream
As defined byUniConstraintStream.ifNotExistsIncludingNullVars(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
SafeVarargs
annotation because it's an interface method. Therefore, there are overloaded methods with up to 4BiJoiner
parameters.- Specified by:
ifNotExistsIncludingNullVars
in 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
BiJoiner
s are true
-
groupBy
public <ResultContainer_,Result_> UniConstraintStream<Result_> groupBy(UniConstraintCollector<A,ResultContainer_,Result_> collector)
Description copied from interface:UniConstraintStream
Convert theUniConstraintStream
to a differentUniConstraintStream
, containing only a single tuple, the result of applyingUniConstraintCollector
.- Specified by:
groupBy
in 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 SeeConstraintCollectors
for 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:UniConstraintStream
Convert theUniConstraintStream
to aBiConstraintStream
, containing only a single tuple, the result of applying twoUniConstraintCollector
s.- Specified by:
groupBy
in 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 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(UniConstraintCollector<A,ResultContainerA_,ResultA_> collectorA, UniConstraintCollector<A,ResultContainerB_,ResultB_> collectorB, UniConstraintCollector<A,ResultContainerC_,ResultC_> collectorC)
Description copied from interface:UniConstraintStream
Convert theUniConstraintStream
to aTriConstraintStream
, containing only a single tuple, the result of applying threeUniConstraintCollector
s.- Specified by:
groupBy
in 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 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(UniConstraintCollector<A,ResultContainerA_,ResultA_> collectorA, UniConstraintCollector<A,ResultContainerB_,ResultB_> collectorB, UniConstraintCollector<A,ResultContainerC_,ResultC_> collectorC, UniConstraintCollector<A,ResultContainerD_,ResultD_> collectorD)
Description copied from interface:UniConstraintStream
Convert theUniConstraintStream
to aQuadConstraintStream
, containing only a single tuple, the result of applying fourUniConstraintCollector
s.- Specified by:
groupBy
in 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 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(Function<A,GroupKey_> groupKeyMapping)
Description copied from interface:UniConstraintStream
Convert theUniConstraintStream
to 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:
groupBy
in 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:UniConstraintStream
Convert theUniConstraintStream
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
UniConstraintCollector
applied on all incoming tuples with the same first fact.- Specified by:
groupBy
in 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 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(Function<A,GroupKey_> groupKeyMapping, UniConstraintCollector<A,ResultContainerB_,ResultB_> collectorB, UniConstraintCollector<A,ResultContainerC_,ResultC_> collectorC, UniConstraintCollector<A,ResultContainerD_,ResultD_> collectorD)
Description copied from interface:UniConstraintStream
Convert theUniConstraintStream
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
UniConstraintCollector
applied on all incoming tuples with the same first fact.- Specified by:
groupBy
in 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 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 <GroupKeyA_,GroupKeyB_> BiConstraintStream<GroupKeyA_,GroupKeyB_> groupBy(Function<A,GroupKeyA_> groupKeyAMapping, Function<A,GroupKeyB_> groupKeyBMapping)
Description copied from interface:UniConstraintStream
Convert theUniConstraintStream
to 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:
groupBy
in 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:UniConstraintStream
Convert theUniConstraintStream
to 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
UniConstraintCollector
applied on all incoming tuples with the same first fact.- Specified by:
groupBy
in 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 SeeConstraintCollectors
for 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:UniConstraintStream
Combines 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 originalUniConstraintStream
that belong to the group.- Specified by:
groupBy
in 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 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(Function<A,GroupKeyA_> groupKeyAMapping, Function<A,GroupKeyB_> groupKeyBMapping, UniConstraintCollector<A,ResultContainerC_,ResultC_> collectorC, UniConstraintCollector<A,ResultContainerD_,ResultD_> collectorD)
Description copied from interface:UniConstraintStream
Combines 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 originalUniConstraintStream
that belong to the group. The fourth fact is the result of applying the secondUniConstraintCollector.finisher()
on all the tuples of the originalUniConstraintStream
that belong to the group- Specified by:
groupBy
in 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 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(Function<A,GroupKeyA_> groupKeyAMapping, Function<A,GroupKeyB_> groupKeyBMapping, Function<A,GroupKeyC_> groupKeyCMapping)
Description copied from interface:UniConstraintStream
Convert theUniConstraintStream
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 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:UniConstraintStream
Combines 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 originalUniConstraintStream
that belong to the group.- Specified by:
groupBy
in 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 SeeConstraintCollectors
for 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:UniConstraintStream
Convert theUniConstraintStream
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 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 ofInteger
s *[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:UniConstraintStream
Transforms 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 likewiseequal
and 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
Person
s[Ann(age = 20), Beth(age = 25), Cathy(age = 30)]
, callingmap(Person::getAge)
on such stream will produce a stream ofInteger
s[20, 25, 30]
,Example with a non-bijective mapping function: assuming a constraint stream of tuples of
Person
s[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 ofInteger
s[20, 25, 30, 30, 20]
.- Specified by:
map
in 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:UniConstraintStream
Takes 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
Person
s[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:
flattenLast
in 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:
impactScore
in classAbstractConstraintStream<Solution_>
-
impactScore
public final Constraint impactScore(String constraintPackage, String constraintName, Score<?> constraintWeight, ToIntFunction<A> matchWeigher, ScoreImpactType impactType)
- Specified by:
impactScore
in interfaceInnerUniConstraintStream<Solution_>
-
impactScoreLong
public final Constraint impactScoreLong(String constraintPackage, String constraintName, Score<?> constraintWeight, ToLongFunction<A> matchWeigher, ScoreImpactType impactType)
- Specified by:
impactScoreLong
in interfaceInnerUniConstraintStream<Solution_>
-
impactScoreBigDecimal
public final Constraint impactScoreBigDecimal(String constraintPackage, String constraintName, Score<?> constraintWeight, Function<A,BigDecimal> matchWeigher, ScoreImpactType impactType)
- Specified by:
impactScoreBigDecimal
in interfaceInnerUniConstraintStream<Solution_>
-
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, ToIntFunction<A> matchWeigher, ScoreImpactType impactType)
- Specified by:
impactScoreConfigurable
in interfaceInnerUniConstraintStream<Solution_>
-
impactScoreConfigurableLong
public final Constraint impactScoreConfigurableLong(String constraintPackage, String constraintName, ToLongFunction<A> matchWeigher, ScoreImpactType impactType)
- Specified by:
impactScoreConfigurableLong
in interfaceInnerUniConstraintStream<Solution_>
-
impactScoreConfigurableBigDecimal
public final Constraint impactScoreConfigurableBigDecimal(String constraintPackage, String constraintName, Function<A,BigDecimal> matchWeigher, ScoreImpactType impactType)
- Specified by:
impactScoreConfigurableBigDecimal
in 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)
-
-