diff options
Diffstat (limited to 'subprojects/logic/src/main/java/tools/refinery/logic/term/real/IntToRealTerm.java')
-rw-r--r-- | subprojects/logic/src/main/java/tools/refinery/logic/term/real/IntToRealTerm.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/subprojects/logic/src/main/java/tools/refinery/logic/term/real/IntToRealTerm.java b/subprojects/logic/src/main/java/tools/refinery/logic/term/real/IntToRealTerm.java new file mode 100644 index 00000000..23c6893c --- /dev/null +++ b/subprojects/logic/src/main/java/tools/refinery/logic/term/real/IntToRealTerm.java | |||
@@ -0,0 +1,31 @@ | |||
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.real; | ||
7 | |||
8 | import tools.refinery.logic.term.UnaryTerm; | ||
9 | import tools.refinery.logic.substitution.Substitution; | ||
10 | import tools.refinery.logic.term.Term; | ||
11 | |||
12 | public class IntToRealTerm extends UnaryTerm<Double, Integer> { | ||
13 | protected IntToRealTerm(Term<Integer> body) { | ||
14 | super(Double.class, Integer.class, body); | ||
15 | } | ||
16 | |||
17 | @Override | ||
18 | protected Term<Double> doSubstitute(Substitution substitution, Term<Integer> substitutedBody) { | ||
19 | return new IntToRealTerm(substitutedBody); | ||
20 | } | ||
21 | |||
22 | @Override | ||
23 | protected Double doEvaluate(Integer bodyValue) { | ||
24 | return bodyValue.doubleValue(); | ||
25 | } | ||
26 | |||
27 | @Override | ||
28 | public String toString() { | ||
29 | return "(%s as real)".formatted(getBody()); | ||
30 | } | ||
31 | } | ||