blob: 1e769259cdc6f84da50f70539a9befee853debc0 (
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
|
package tools.refinery.store.query.term.int_;
import tools.refinery.store.query.substitution.Substitution;
import tools.refinery.store.query.term.Term;
import tools.refinery.store.query.term.ArithmeticUnaryOperator;
import tools.refinery.store.query.term.ArithmeticUnaryTerm;
public class IntArithmeticUnaryTerm extends ArithmeticUnaryTerm<Integer> {
public IntArithmeticUnaryTerm(ArithmeticUnaryOperator operation, Term<Integer> body) {
super(operation, body);
}
@Override
public Class<Integer> getType() {
return Integer.class;
}
@Override
protected Term<Integer> doSubstitute(Substitution substitution, Term<Integer> substitutedBody) {
return new IntArithmeticUnaryTerm(getOperator(), substitutedBody);
}
@Override
protected Integer doEvaluate(Integer bodyValue) {
return switch(getOperator()) {
case PLUS -> bodyValue;
case MINUS -> -bodyValue;
};
}
}
|