@Override protected Node copy(Node parent) { NodeVariableDefinition node = new NodeVariableDefinition(parent); node.id = this.id; Node n = (Node) getNodeValue(); if (n != null) { node.value = n.copy(parent); } node.value = this.value; return node; }
@Override public String getValue() { if (isUndefined()) { LOGGER.error("trying to access a non defined variable"); return null; } if (!isVar()) { return value.getValue(); } LOGGER.trace("We found a reference"); String varName = value.getValue(); NodeVariableDefinition element = getVariableByName(varName); if (element == null) { LOGGER.error("Var not found"); return null; } if (element.value.getValue().equals(varName)) { LOGGER.error("Found a circular reference"); } return element.getValue(); }
/** * two variables are equals if they have the same id and type * * @param other * @return true if both variables are the same */ public boolean equals(NodeVariableDefinition other) { return other.id.equals(this.id) && other.getParent() == getParent(); }