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