
org.optaplanner.constraint.streams.drools.common.PatternVariable Maven / Gradle / Ivy
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.optaplanner.constraint.streams.drools.common;
import java.util.List;
import java.util.function.BiFunction;
import java.util.function.BiPredicate;
import java.util.function.Function;
import java.util.function.Predicate;
import org.drools.model.Variable;
import org.drools.model.view.ViewItem;
import org.optaplanner.constraint.streams.common.bi.DefaultBiJoiner;
import org.optaplanner.constraint.streams.common.quad.DefaultQuadJoiner;
import org.optaplanner.constraint.streams.common.tri.DefaultTriJoiner;
import org.optaplanner.core.api.function.QuadFunction;
import org.optaplanner.core.api.function.QuadPredicate;
import org.optaplanner.core.api.function.TriFunction;
import org.optaplanner.core.api.function.TriPredicate;
import org.optaplanner.core.impl.score.stream.JoinerType;
public interface PatternVariable> {
Variable getPrimaryVariable();
List> getPrerequisiteExpressions();
List> getDependentExpressions();
Child_ filter(Predicate predicate);
Child_ filter(BiPredicate predicate, Variable leftJoinVariable);
Child_ filter(TriPredicate predicate,
Variable leftJoinVariableA, Variable leftJoinVariableB);
Child_ filter(
QuadPredicate predicate,
Variable leftJoinVariableA, Variable leftJoinVariableB,
Variable leftJoinVariableC);
PatternVariable filterForJoin(Variable leftJoinVar,
DefaultBiJoiner joiner, JoinerType joinerType, int mappingIndex);
PatternVariable filterForJoin(Variable leftJoinVarA,
Variable leftJoinVarB, DefaultTriJoiner joiner,
JoinerType joinerType, int mappingIndex);
PatternVariable filterForJoin(
Variable leftJoinVarA, Variable leftJoinVarB, Variable leftJoinVarC,
DefaultQuadJoiner joiner, JoinerType joinerType,
int mappingIndex);
/**
* Bind a new variable.
* This call is safe for use outside accumulate() and groupBy(),
* unlike {@link #bind(Variable, Variable, BiFunction)} etc.
*
* @param boundVariable the new variable
* @param bindingFunction the function to apply to create the bound variable
* @param generic type of the bound variable
* @return never null
*/
Child_ bind(Variable boundVariable, Function bindingFunction);
/**
* This must only be used in patterns that will eventually end up in accumulate() or groupBy().
* Drools does not support binding 2+ variables outside of accumulate() or groupBy().
* Disobeying will result in Drools {@link NullPointerException} at runtime.
*
* @param boundVariable the new variable
* @param leftJoinVariable the variable to use when creating the bound variable
* @param bindingFunction the function to apply to create the bound variable
* @param generic type of the bound variable
* @param generic type of the join variable
* @return never null
*/
Child_ bind(Variable boundVariable, Variable leftJoinVariable,
BiFunction bindingFunction);
/**
* As defined by {@link #bind(Variable, Variable, BiFunction)}.
*
* @param boundVariable the new variable
* @param leftJoinVariableA the first variable to use when creating the bound variable
* @param leftJoinVariableB the second variable to use when creating the bound variable
* @param bindingFunction the function to apply to create the bound variable
* @param generic type of the bound variable
* @param generic type of the first join variable
* @param generic type of the second join variable
* @return never null
*/
Child_ bind(Variable boundVariable,
Variable leftJoinVariableA, Variable leftJoinVariableB,
TriFunction bindingFunction);
/**
* As defined by {@link #bind(Variable, Variable, BiFunction)}.
*
* @param boundVariable the new variable
* @param leftJoinVariableA the first variable to use when creating the bound variable
* @param leftJoinVariableB the second variable to use when creating the bound variable
* @param leftJoinVariableC the third variable to use when creating the bound variable
* @param bindingFunction the function to apply to create the bound variable
* @param generic type of the bound variable
* @param generic type of the first join variable
* @param generic type of the second join variable
* @param generic type of the third join variable
* @return never null
*/
Child_ bind(Variable boundVariable,
Variable leftJoinVariableA, Variable leftJoinVariableB,
Variable leftJoinVariableC,
QuadFunction bindingFunction);
Child_ addDependentExpression(ViewItem> expression);
List> build();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy