org.optaplanner.constraint.streams.bavet.uni.IfExistsUniWithUniNode 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.uni;
import java.util.Set;
import java.util.function.BiPredicate;
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;
final class IfExistsUniWithUniNode extends AbstractIfExistsNode, B> {
private final Function mappingA;
private final BiPredicate filtering;
public IfExistsUniWithUniNode(boolean shouldExist,
Function mappingA, Function mappingB,
int inputStoreIndexA, int inputStoreIndexB,
TupleLifecycle> nextNodesTupleLifecycle,
Indexer, Counter>> indexerA,
Indexer, Set>>> indexerB,
BiPredicate filtering) {
super(shouldExist, mappingB, inputStoreIndexA, inputStoreIndexB, nextNodesTupleLifecycle, indexerA, indexerB);
this.mappingA = mappingA;
this.filtering = filtering;
}
@Override
protected IndexProperties createIndexProperties(UniTuple leftTuple) {
return mappingA.apply(leftTuple.getFactA());
}
@Override
protected boolean isFiltering() {
return filtering != null;
}
@Override
protected boolean isFiltered(UniTuple leftTuple, UniTuple rightTuple) {
return filtering.test(leftTuple.getFactA(), rightTuple.getFactA());
}
@Override
public String toString() {
return "IfExistsUniWithUniNode";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy