diff options
Diffstat (limited to 'subprojects/store-query/src/main/java/tools/refinery/store/query/term/ArithmeticBinaryOperator.java')
-rw-r--r-- | subprojects/store-query/src/main/java/tools/refinery/store/query/term/ArithmeticBinaryOperator.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/subprojects/store-query/src/main/java/tools/refinery/store/query/term/ArithmeticBinaryOperator.java b/subprojects/store-query/src/main/java/tools/refinery/store/query/term/ArithmeticBinaryOperator.java new file mode 100644 index 00000000..8706a046 --- /dev/null +++ b/subprojects/store-query/src/main/java/tools/refinery/store/query/term/ArithmeticBinaryOperator.java | |||
@@ -0,0 +1,26 @@ | |||
1 | package tools.refinery.store.query.term; | ||
2 | |||
3 | public enum ArithmeticBinaryOperator { | ||
4 | ADD("+", true), | ||
5 | SUB("-", true), | ||
6 | MUL("*", true), | ||
7 | DIV("/", true), | ||
8 | POW("**", true), | ||
9 | MIN("min", false), | ||
10 | MAX("max", false); | ||
11 | |||
12 | private final String text; | ||
13 | private final boolean infix; | ||
14 | |||
15 | ArithmeticBinaryOperator(String text, boolean infix) { | ||
16 | this.text = text; | ||
17 | this.infix = infix; | ||
18 | } | ||
19 | |||
20 | public String formatString(String left, String right) { | ||
21 | if (infix) { | ||
22 | return "(%s) %s (%s)".formatted(left, text, right); | ||
23 | } | ||
24 | return "%s(%s, %s)".formatted(text, left, right); | ||
25 | } | ||
26 | } | ||