diff options
Diffstat (limited to 'subprojects/logic/src/main/java/tools/refinery/logic/term/comparable/LessTerm.java')
-rw-r--r-- | subprojects/logic/src/main/java/tools/refinery/logic/term/comparable/LessTerm.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/subprojects/logic/src/main/java/tools/refinery/logic/term/comparable/LessTerm.java b/subprojects/logic/src/main/java/tools/refinery/logic/term/comparable/LessTerm.java new file mode 100644 index 00000000..b402f54d --- /dev/null +++ b/subprojects/logic/src/main/java/tools/refinery/logic/term/comparable/LessTerm.java | |||
@@ -0,0 +1,30 @@ | |||
1 | /* | ||
2 | * SPDX-FileCopyrightText: 2021-2023 The Refinery Authors <https://refinery.tools/> | ||
3 | * | ||
4 | * SPDX-License-Identifier: EPL-2.0 | ||
5 | */ | ||
6 | package tools.refinery.logic.term.comparable; | ||
7 | |||
8 | import tools.refinery.logic.substitution.Substitution; | ||
9 | import tools.refinery.logic.term.Term; | ||
10 | |||
11 | public class LessTerm<T extends Comparable<T>> extends ComparisonTerm<T> { | ||
12 | public LessTerm(Class<T> argumentType, Term<T> left, Term<T> right) { | ||
13 | super(argumentType, left, right); | ||
14 | } | ||
15 | |||
16 | @Override | ||
17 | protected Boolean doEvaluate(T leftValue, T rightValue) { | ||
18 | return leftValue.compareTo(rightValue) < 0; | ||
19 | } | ||
20 | |||
21 | @Override | ||
22 | public Term<Boolean> doSubstitute(Substitution substitution, Term<T> substitutedLeft, Term<T> substitutedRight) { | ||
23 | return new LessTerm<>(getArgumentType(), substitutedLeft, substitutedRight); | ||
24 | } | ||
25 | |||
26 | @Override | ||
27 | public String toString() { | ||
28 | return "(%s < %s)".formatted(getLeft(), getRight()); | ||
29 | } | ||
30 | } | ||