org.optaplanner.constraint.streams.bavet.bi.IfExistsBiWithUniNode Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of optaplanner-constraint-streams-bavet Show documentation
Show all versions of optaplanner-constraint-streams-bavet Show documentation
OptaPlanner solves planning problems.
This lightweight, embeddable planning engine implements powerful and scalable algorithms
to optimize business resource scheduling and planning.
This module contains implementation of Constraint streams (Bavet).
package org.optaplanner.constraint.streams.bavet.bi;
import java.util.Set;
import java.util.function.BiFunction;
import java.util.function.Function;
import org.optaplanner.constraint.streams.bavet.common.AbstractIfExistsNode;
import org.optaplanner.constraint.streams.bavet.common.TupleLifecycle;
import org.optaplanner.constraint.streams.bavet.common.index.IndexProperties;
import org.optaplanner.constraint.streams.bavet.common.index.Indexer;
import org.optaplanner.constraint.streams.bavet.uni.UniTuple;
import org.optaplanner.core.api.function.TriPredicate;
final class IfExistsBiWithUniNode extends AbstractIfExistsNode, C> {
private final BiFunction mappingAB;
private final TriPredicate filtering;
public IfExistsBiWithUniNode(boolean shouldExist,
BiFunction mappingAB, Function mappingC,
int inputStoreIndexAB, int inputStoreIndexC,
TupleLifecycle> tupleLifecycle,
Indexer, Counter>> indexerAB,
Indexer, Set>>> indexerC,
TriPredicate filtering) {
super(shouldExist, mappingC, inputStoreIndexAB, inputStoreIndexC, tupleLifecycle, indexerAB, indexerC);
this.mappingAB = mappingAB;
this.filtering = filtering;
}
@Override
protected IndexProperties createIndexProperties(BiTuple leftTuple) {
return mappingAB.apply(leftTuple.getFactA(), leftTuple.getFactB());
}
@Override
protected boolean isFiltering() {
return filtering != null;
}
@Override
protected boolean isFiltered(BiTuple leftTuple, UniTuple rightTuple) {
return filtering.test(leftTuple.getFactA(), leftTuple.getFactB(), rightTuple.getFactA());
}
@Override
public String toString() {
return "IfExistsBiWithUniNode";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy