aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/logic/src/main/java/tools/refinery/logic/term/comparable/LessEqTerm.java
blob: 7a07b7b281cfa0b399287a08618cd3398b28fd02 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
 * SPDX-FileCopyrightText: 2021-2023 The Refinery Authors <https://refinery.tools/>
 *
 * SPDX-License-Identifier: EPL-2.0
 */
package tools.refinery.logic.term.comparable;

import tools.refinery.logic.substitution.Substitution;
import tools.refinery.logic.term.Term;

public class LessEqTerm<T extends Comparable<T>> extends ComparisonTerm<T> {
	public LessEqTerm(Class<T> argumentType, Term<T> left, Term<T> right) {
		super(argumentType, left, right);
	}

	@Override
	protected Boolean doEvaluate(T leftValue, T rightValue) {
		return leftValue.compareTo(rightValue) <= 0;
	}

	@Override
	public Term<Boolean> doSubstitute(Substitution substitution, Term<T> substitutedLeft, Term<T> substitutedRight) {
		return new LessEqTerm<>(getArgumentType(), substitutedLeft, substitutedRight);
	}

	@Override
	public String toString() {
		return "(%s <= %s)".formatted(getLeft(), getRight());
	}
}