org.optaplanner.constraint.streams.bavet.common.AbstractConditionalTupleLifecycle 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.common;
import java.util.Objects;
public abstract class AbstractConditionalTupleLifecycle
implements TupleLifecycle {
private final TupleLifecycle tupleLifecycle;
protected AbstractConditionalTupleLifecycle(TupleLifecycle tupleLifecycle) {
this.tupleLifecycle = Objects.requireNonNull(tupleLifecycle);
}
@Override
public final void insert(Tuple_ tuple) {
if (test(tuple)) {
tupleLifecycle.insert(tuple);
}
}
@Override
public final void update(Tuple_ tuple) {
if (test(tuple)) {
tupleLifecycle.update(tuple);
} else {
tupleLifecycle.retract(tuple);
}
}
@Override
public final void retract(Tuple_ tuple) {
tupleLifecycle.retract(tuple);
}
abstract protected boolean test(Tuple_ tuple);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy