blob: 8522f2c1cf2f22ac3f398f14f28bd28ce6706879 (
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
31
32
33
34
35
|
/*
* SPDX-FileCopyrightText: 2021-2023 The Refinery Authors <https://refinery.tools/>
*
* SPDX-License-Identifier: EPL-2.0
*/
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;
};
}
}
|