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