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
|
package tools.refinery.store.query.term;
public enum ArithmeticBinaryOperator {
ADD("+", true),
SUB("-", true),
MUL("*", true),
DIV("/", true),
POW("**", true),
MIN("min", false),
MAX("max", false);
private final String text;
private final boolean infix;
ArithmeticBinaryOperator(String text, boolean infix) {
this.text = text;
this.infix = infix;
}
public String formatString(String left, String right) {
if (infix) {
return "(%s) %s (%s)".formatted(left, text, right);
}
return "%s(%s, %s)".formatted(text, left, right);
}
}
|