All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.optaplanner.constraint.streams.bavet.common.AbstractConditionalTupleLifecycle Maven / Gradle / Ivy

Go to download

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).

There is a newer version: 10.0.0
Show newest version
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