public abstract class DroolsAbstractBiConstraintStream<Solution_,A,B> extends DroolsAbstractConstraintStream<Solution_> implements InnerBiConstraintStream<A,B>
constraintFactory
Constructor and Description |
---|
DroolsAbstractBiConstraintStream(DroolsConstraintFactory<Solution_> constraintFactory) |
Modifier and Type | Method and Description |
---|---|
BiConstraintStream<A,B> |
filter(BiPredicate<A,B> predicate)
Exhaustively test each tuple of facts against the
BiPredicate
and match if BiPredicate.test(Object, Object) returns true. |
abstract DroolsBiCondition<A,B> |
getCondition() |
List<DroolsFromUniConstraintStream<Solution_,Object>> |
getFromStreamList() |
protected abstract DroolsAbstractConstraintStream<Solution_> |
getParent() |
<ResultContainer_,Result_> |
groupBy(BiConstraintCollector<A,B,ResultContainer_,Result_> collector)
Runs all tuples of the stream through a given @
BiConstraintCollector and converts them into a new
UniConstraintStream which only has a single tuple, the result of applying BiConstraintCollector . |
<GroupKey_> |
groupBy(BiFunction<A,B,GroupKey_> groupKeyMapping)
Convert the
BiConstraintStream to a UniConstraintStream , containing the set of tuples resulting
from applying the group key mapping function on all tuples of the original stream. |
<GroupKey_,__,Result_> |
groupBy(BiFunction<A,B,GroupKey_> groupKeyMapping,
BiConstraintCollector<A,B,__,Result_> collector)
Convert the
BiConstraintStream to a different BiConstraintStream , consisting of unique tuples. |
<GroupKeyA_,GroupKeyB_> |
groupBy(BiFunction<A,B,GroupKeyA_> groupKeyAMapping,
BiFunction<A,B,GroupKeyB_> groupKeyBMapping)
Convert the
BiConstraintStream to a different BiConstraintStream , consisting of unique tuples. |
<GroupKeyA_,GroupKeyB_,ResultContainer_,Result_> |
groupBy(BiFunction<A,B,GroupKeyA_> groupKeyAMapping,
BiFunction<A,B,GroupKeyB_> groupKeyBMapping,
BiConstraintCollector<A,B,ResultContainer_,Result_> collector)
Combines the semantics of
BiConstraintStream.groupBy(BiFunction, BiFunction) and BiConstraintStream.groupBy(BiConstraintCollector) . |
<GroupKeyA_,GroupKeyB_,ResultContainerC_,ResultC_,ResultContainerD_,ResultD_> |
groupBy(BiFunction<A,B,GroupKeyA_> groupKeyAMapping,
BiFunction<A,B,GroupKeyB_> groupKeyBMapping,
BiConstraintCollector<A,B,ResultContainerC_,ResultC_> collectorC,
BiConstraintCollector<A,B,ResultContainerD_,ResultD_> collectorD)
Combines the semantics of
BiConstraintStream.groupBy(BiFunction, BiFunction) and BiConstraintStream.groupBy(BiConstraintCollector) . |
Constraint |
impactScore(String constraintPackage,
String constraintName,
Score<?> constraintWeight,
boolean positive) |
Constraint |
impactScore(String constraintPackage,
String constraintName,
Score<?> constraintWeight,
ToIntBiFunction<A,B> matchWeigher,
boolean positive) |
Constraint |
impactScoreBigDecimal(String constraintPackage,
String constraintName,
Score<?> constraintWeight,
BiFunction<A,B,BigDecimal> matchWeigher,
boolean positive) |
Constraint |
impactScoreConfigurable(String constraintPackage,
String constraintName,
boolean positive) |
Constraint |
impactScoreConfigurable(String constraintPackage,
String constraintName,
ToIntBiFunction<A,B> matchWeigher,
boolean positive) |
Constraint |
impactScoreConfigurableBigDecimal(String constraintPackage,
String constraintName,
BiFunction<A,B,BigDecimal> matchWeigher,
boolean positive) |
Constraint |
impactScoreConfigurableLong(String constraintPackage,
String constraintName,
ToLongBiFunction<A,B> matchWeigher,
boolean positive) |
Constraint |
impactScoreLong(String constraintPackage,
String constraintName,
Score<?> constraintWeight,
ToLongBiFunction<A,B> matchWeigher,
boolean positive) |
boolean |
isGroupByAllowed() |
<C> TriConstraintStream<A,B,C> |
join(UniConstraintStream<C> otherStream,
TriJoiner<A,B,C> joiner)
Create a new
TriConstraintStream for every combination of [A, B] and C for which the TriJoiner
is true (for the properties it extracts from both facts). |
addChildStream, buildConstraint, buildConstraintConfigurable, createRuleItemBuilders, getChildStreams, getConstraintFactory, throwWhenGroupByNotAllowed
buildConstraintWeightExtractor, buildConstraintWeightExtractor, penalize, penalizeConfigurable, reward, rewardConfigurable, validateConstraintId
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
penalize, penalizeBigDecimal, penalizeConfigurable, penalizeConfigurableBigDecimal, penalizeConfigurableLong, penalizeLong, reward, rewardBigDecimal, rewardConfigurable, rewardConfigurableBigDecimal, rewardConfigurableLong, rewardLong
join, join, join, join, join, join, join, penalize, penalizeBigDecimal, penalizeConfigurable, penalizeConfigurableBigDecimal, penalizeConfigurableLong, penalizeLong, reward, rewardBigDecimal, rewardConfigurable, rewardConfigurableBigDecimal, rewardConfigurableLong, rewardLong
getConstraintFactory, penalize, penalize, penalizeConfigurable, penalizeConfigurable, reward, reward, rewardConfigurable, rewardConfigurable
public DroolsAbstractBiConstraintStream(DroolsConstraintFactory<Solution_> constraintFactory)
public BiConstraintStream<A,B> filter(BiPredicate<A,B> predicate)
BiConstraintStream
BiPredicate
and match if BiPredicate.test(Object, Object)
returns true.
Important: This is slower and less scalable than UniConstraintStream.join(UniConstraintStream, BiJoiner)
with a proper BiJoiner
predicate (such as Joiners.equal(Function, Function)
,
because the latter applies hashing and/or indexing, so it doesn't create every combination just to filter it out.
filter
in interface BiConstraintStream<A,B>
predicate
- never nullpublic <C> TriConstraintStream<A,B,C> join(UniConstraintStream<C> otherStream, TriJoiner<A,B,C> joiner)
BiConstraintStream
TriConstraintStream
for every combination of [A, B] and C for which the TriJoiner
is true (for the properties it extracts from both facts).
Important: This is faster and more scalable than a join
followed by a filter
,
because it applies hashing and/or indexing on the properties,
so it doesn't create nor checks every combination of [A, B] and C.
join
in interface BiConstraintStream<A,B>
C
- the type of the third matched factotherStream
- never nulljoiner
- never nullTriFunction
is truepublic <ResultContainer_,Result_> UniConstraintStream<Result_> groupBy(BiConstraintCollector<A,B,ResultContainer_,Result_> collector)
BiConstraintStream
BiConstraintCollector
and converts them into a new
UniConstraintStream
which only has a single tuple, the result of applying BiConstraintCollector
.groupBy
in interface BiConstraintStream<A,B>
ResultContainer_
- the mutable accumulation type (often hidden as an implementation detail)Result_
- the type of a fact in the destination UniConstraintStream
's tuplecollector
- never null, the collector to perform the grouping operation withpublic <GroupKey_> UniConstraintStream<GroupKey_> groupBy(BiFunction<A,B,GroupKey_> groupKeyMapping)
BiConstraintStream
BiConstraintStream
to a UniConstraintStream
, 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 stream Objects.equals(Object, Object)
any other.groupBy
in interface BiConstraintStream<A,B>
GroupKey_
- the type of a fact in the destination UniConstraintStream
's tuplegroupKeyMapping
- never null, mapping function to convert each element in the stream to a different elementpublic <GroupKey_,__,Result_> BiConstraintStream<GroupKey_,Result_> groupBy(BiFunction<A,B,GroupKey_> groupKeyMapping, BiConstraintCollector<A,B,__,Result_> collector)
BiConstraintStream
BiConstraintStream
to a different BiConstraintStream
, consisting of unique tuples.
The first fact is the return value of the first group key mapping function, applied on the incoming tuple.
The second fact is the return value of a given BiConstraintCollector
applied on all incoming tuples with
the same first fact.
groupBy
in interface BiConstraintStream<A,B>
GroupKey_
- the type of the first fact in the destination BiConstraintStream
's tuple__
- the mutable accumulation type (often hidden as an implementation detail)Result_
- the type of the second fact in the destination BiConstraintStream
's tuplegroupKeyMapping
- never null, function to convert the fact in the original tuple to a different factpublic <GroupKeyA_,GroupKeyB_> BiConstraintStream<GroupKeyA_,GroupKeyB_> groupBy(BiFunction<A,B,GroupKeyA_> groupKeyAMapping, BiFunction<A,B,GroupKeyB_> groupKeyBMapping)
BiConstraintStream
BiConstraintStream
to a different BiConstraintStream
, consisting of unique tuples.
The first fact is the return value of the first group key mapping function, applied on the incoming tuple. The second fact is the return value of the second group key mapping function, applied on all incoming tuples with the same first fact.
groupBy
in interface BiConstraintStream<A,B>
GroupKeyA_
- the type of the first fact in the destination BiConstraintStream
's tupleGroupKeyB_
- the type of the second fact in the destination BiConstraintStream
's tuplegroupKeyAMapping
- never null, function to convert the facts in the original tuple to a new factgroupKeyBMapping
- never null, function to convert the facts in the original tuple to another new factpublic <GroupKeyA_,GroupKeyB_,ResultContainer_,Result_> TriConstraintStream<GroupKeyA_,GroupKeyB_,Result_> groupBy(BiFunction<A,B,GroupKeyA_> groupKeyAMapping, BiFunction<A,B,GroupKeyB_> groupKeyBMapping, BiConstraintCollector<A,B,ResultContainer_,Result_> collector)
BiConstraintStream
BiConstraintStream.groupBy(BiFunction, BiFunction)
and BiConstraintStream.groupBy(BiConstraintCollector)
.
That is, the first and second facts in the tuple follow the BiConstraintStream.groupBy(BiFunction, BiFunction)
semantics,
and the third fact is the result of applying BiConstraintCollector.finisher()
on all the tuples of the
original UniConstraintStream
that belong to the group.groupBy
in interface BiConstraintStream<A,B>
GroupKeyA_
- the type of the first fact in the destination TriConstraintStream
's tupleGroupKeyB_
- the type of the second fact in the destination TriConstraintStream
's tupleResultContainer_
- the mutable accumulation type (often hidden as an implementation detail)Result_
- the type of the third fact in the destination TriConstraintStream
's tuplegroupKeyAMapping
- 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 withpublic <GroupKeyA_,GroupKeyB_,ResultContainerC_,ResultC_,ResultContainerD_,ResultD_> QuadConstraintStream<GroupKeyA_,GroupKeyB_,ResultC_,ResultD_> groupBy(BiFunction<A,B,GroupKeyA_> groupKeyAMapping, BiFunction<A,B,GroupKeyB_> groupKeyBMapping, BiConstraintCollector<A,B,ResultContainerC_,ResultC_> collectorC, BiConstraintCollector<A,B,ResultContainerD_,ResultD_> collectorD)
BiConstraintStream
BiConstraintStream.groupBy(BiFunction, BiFunction)
and BiConstraintStream.groupBy(BiConstraintCollector)
.
That is, the first and second facts in the tuple follow the BiConstraintStream.groupBy(BiFunction, BiFunction)
semantics.
The third fact is the result of applying the first BiConstraintCollector.finisher()
on all the tuples
of the original BiConstraintStream
that belong to the group.
The fourth fact is the result of applying the second BiConstraintCollector.finisher()
on all the tuples
of the original BiConstraintStream
that belong to the groupgroupBy
in interface BiConstraintStream<A,B>
GroupKeyA_
- the type of the first fact in the destination QuadConstraintStream
's tupleGroupKeyB_
- the type of the second fact in the destination QuadConstraintStream
's tupleResultContainerC_
- the mutable accumulation type (often hidden as an implementation detail)ResultC_
- the type of the third fact in the destination QuadConstraintStream
's tupleResultContainerD_
- the mutable accumulation type (often hidden as an implementation detail)ResultD_
- the type of the fourth fact in the destination QuadConstraintStream
's tuplegroupKeyAMapping
- 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 withcollectorD
- never null, the collector to perform the first grouping operation withpublic final Constraint impactScore(String constraintPackage, String constraintName, Score<?> constraintWeight, boolean positive)
impactScore
in class AbstractConstraintStream<Solution_>
public final Constraint impactScore(String constraintPackage, String constraintName, Score<?> constraintWeight, ToIntBiFunction<A,B> matchWeigher, boolean positive)
impactScore
in interface InnerBiConstraintStream<A,B>
public final Constraint impactScoreLong(String constraintPackage, String constraintName, Score<?> constraintWeight, ToLongBiFunction<A,B> matchWeigher, boolean positive)
impactScoreLong
in interface InnerBiConstraintStream<A,B>
public final Constraint impactScoreBigDecimal(String constraintPackage, String constraintName, Score<?> constraintWeight, BiFunction<A,B,BigDecimal> matchWeigher, boolean positive)
impactScoreBigDecimal
in interface InnerBiConstraintStream<A,B>
public final Constraint impactScoreConfigurable(String constraintPackage, String constraintName, boolean positive)
impactScoreConfigurable
in class AbstractConstraintStream<Solution_>
public final Constraint impactScoreConfigurable(String constraintPackage, String constraintName, ToIntBiFunction<A,B> matchWeigher, boolean positive)
impactScoreConfigurable
in interface InnerBiConstraintStream<A,B>
public final Constraint impactScoreConfigurableLong(String constraintPackage, String constraintName, ToLongBiFunction<A,B> matchWeigher, boolean positive)
impactScoreConfigurableLong
in interface InnerBiConstraintStream<A,B>
public final Constraint impactScoreConfigurableBigDecimal(String constraintPackage, String constraintName, BiFunction<A,B,BigDecimal> matchWeigher, boolean positive)
impactScoreConfigurableBigDecimal
in interface InnerBiConstraintStream<A,B>
public List<DroolsFromUniConstraintStream<Solution_,Object>> getFromStreamList()
getFromStreamList
in class DroolsAbstractConstraintStream<Solution_>
protected abstract DroolsAbstractConstraintStream<Solution_> getParent()
public abstract DroolsBiCondition<A,B> getCondition()
public boolean isGroupByAllowed()
isGroupByAllowed
in class DroolsAbstractConstraintStream<Solution_>
Copyright © 2006–2020 JBoss by Red Hat. All rights reserved.