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 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.int
getCardinality()
<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.<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_,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
.<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)
.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(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).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
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, 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)
-
getCardinality
public int getCardinality()
- Specified by:
getCardinality
in classAbstractConstraintStream<Solution_>
-
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
-
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
-
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
-
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 <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 <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 first 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
-
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)
-
-