name:
src/main/java/io/protobase/f7/models/UnaryMinusOperationNode.java
-rw-r--r--
1063
1package io.protobase.f7.models;
2
3import com.google.common.base.MoreObjects;
4
5/**
6 * Unary minus operation is the highest precedence operation, and is given a special node. While we could achieve this
7 * by creating a formula-node that is functionally the same thing, I like the idea of 1) getting specific with out
8 * node sub-classes, and 2) having something we can render as valid F7 code without mutating the user's input.
9 */
10public class UnaryMinusOperationNode extends BaseObject implements Node {
11 private Node operand;
12
13 /**
14 * Create new node with an operand.
15 *
16 * @param operand value
17 */
18 public UnaryMinusOperationNode(Node operand) {
19 this.operand = operand;
20 }
21
22 /**
23 * Get the operand node.
24 *
25 * @return node.
26 */
27 public Node getOperand() {
28 return operand;
29 }
30
31 @Override
32 public String toString() {
33 return MoreObjects.toStringHelper(this)
34 .add("operand", operand)
35 .toString();
36 }
37
38 @Override
39 public Object[] significantAttributes() {
40 return new Object[]{
41 operand
42 };
43 }
44}