org.optaplanner.constraint.streams.common.tri.TriConstraintBuilderImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of optaplanner-constraint-streams-common Show documentation
Show all versions of optaplanner-constraint-streams-common 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 classes common to each implementation of Constraint streams.
The newest version!
/*
* 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.common.tri;
import java.util.Collection;
import java.util.Objects;
import org.optaplanner.constraint.streams.common.AbstractConstraintBuilder;
import org.optaplanner.constraint.streams.common.ScoreImpactType;
import org.optaplanner.core.api.function.QuadFunction;
import org.optaplanner.core.api.function.TriFunction;
import org.optaplanner.core.api.score.Score;
import org.optaplanner.core.api.score.stream.ConstraintJustification;
import org.optaplanner.core.api.score.stream.tri.TriConstraintBuilder;
public final class TriConstraintBuilderImpl>
extends AbstractConstraintBuilder
implements TriConstraintBuilder {
private QuadFunction justificationMapping;
private TriFunction> indictedObjectsMapping;
public TriConstraintBuilderImpl(TriConstraintConstructor constraintConstructor, ScoreImpactType impactType,
Score_ constraintWeight) {
super(constraintConstructor, impactType, constraintWeight);
}
@Override
protected QuadFunction getJustificationMapping() {
return justificationMapping;
}
@Override
public TriConstraintBuilder justifyWith(
QuadFunction justificationMapping) {
if (this.justificationMapping != null) {
throw new IllegalStateException("Justification mapping already set (" + justificationMapping + ").");
}
this.justificationMapping =
(QuadFunction) Objects.requireNonNull(justificationMapping);
return this;
}
@Override
protected TriFunction> getIndictedObjectsMapping() {
return indictedObjectsMapping;
}
@Override
public TriConstraintBuilder indictWith(TriFunction> indictedObjectsMapping) {
if (this.indictedObjectsMapping != null) {
throw new IllegalStateException("Indicted objects' mapping already set (" + indictedObjectsMapping + ").");
}
this.indictedObjectsMapping = Objects.requireNonNull(indictedObjectsMapping);
return this;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy