diff options
Diffstat (limited to 'subprojects/store-query/src/main/java/tools/refinery/store/query/term/int_/IntArithmeticUnaryTerm.java')
-rw-r--r-- | subprojects/store-query/src/main/java/tools/refinery/store/query/term/int_/IntArithmeticUnaryTerm.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/subprojects/store-query/src/main/java/tools/refinery/store/query/term/int_/IntArithmeticUnaryTerm.java b/subprojects/store-query/src/main/java/tools/refinery/store/query/term/int_/IntArithmeticUnaryTerm.java new file mode 100644 index 00000000..1e769259 --- /dev/null +++ b/subprojects/store-query/src/main/java/tools/refinery/store/query/term/int_/IntArithmeticUnaryTerm.java | |||
@@ -0,0 +1,30 @@ | |||
1 | package tools.refinery.store.query.term.int_; | ||
2 | |||
3 | import tools.refinery.store.query.substitution.Substitution; | ||
4 | import tools.refinery.store.query.term.Term; | ||
5 | import tools.refinery.store.query.term.ArithmeticUnaryOperator; | ||
6 | import tools.refinery.store.query.term.ArithmeticUnaryTerm; | ||
7 | |||
8 | public class IntArithmeticUnaryTerm extends ArithmeticUnaryTerm<Integer> { | ||
9 | public IntArithmeticUnaryTerm(ArithmeticUnaryOperator operation, Term<Integer> body) { | ||
10 | super(operation, body); | ||
11 | } | ||
12 | |||
13 | @Override | ||
14 | public Class<Integer> getType() { | ||
15 | return Integer.class; | ||
16 | } | ||
17 | |||
18 | @Override | ||
19 | protected Term<Integer> doSubstitute(Substitution substitution, Term<Integer> substitutedBody) { | ||
20 | return new IntArithmeticUnaryTerm(getOperator(), substitutedBody); | ||
21 | } | ||
22 | |||
23 | @Override | ||
24 | protected Integer doEvaluate(Integer bodyValue) { | ||
25 | return switch(getOperator()) { | ||
26 | case PLUS -> bodyValue; | ||
27 | case MINUS -> -bodyValue; | ||
28 | }; | ||
29 | } | ||
30 | } | ||