org.optaplanner.constraint.streams.bavet.tri.IfExistsTriWithUniNode 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.tri;
import java.util.Set;
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.QuadPredicate;
import org.optaplanner.core.api.function.TriFunction;
final class IfExistsTriWithUniNode extends AbstractIfExistsNode, D> {
private final TriFunction mappingABC;
private final QuadPredicate filtering;
public IfExistsTriWithUniNode(boolean shouldExist,
TriFunction mappingABC, Function mappingD,
int inputStoreIndexABC, int inputStoreIndexD,
TupleLifecycle> nextNodesTupleLifecycle,
Indexer, Counter>> indexerABC,
Indexer, Set>>> indexerD,
QuadPredicate filtering) {
super(shouldExist, mappingD, inputStoreIndexABC, inputStoreIndexD, nextNodesTupleLifecycle, indexerABC,
indexerD);
this.mappingABC = mappingABC;
this.filtering = filtering;
}
@Override
protected IndexProperties createIndexProperties(TriTuple leftTuple) {
return mappingABC.apply(leftTuple.getFactA(), leftTuple.getFactB(), leftTuple.getFactC());
}
@Override
protected boolean isFiltering() {
return filtering != null;
}
@Override
protected boolean isFiltered(TriTuple leftTuple, UniTuple rightTuple) {
return filtering.test(leftTuple.getFactA(), leftTuple.getFactB(), leftTuple.getFactC(), rightTuple.getFactA());
}
@Override
public String toString() {
return "IfExistsTriWithUniNode";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy