@Override public String toString() { StringBuilder sb = new StringBuilder(); for(AttributeNode.Item item : attribute.getItems()) { sb.append(item.getName()).append("."); } sb.deleteCharAt(sb.length() - 1); return sb.toString() + ":" + comparison.getOperator() + now; }
public void visit(ComparisonNode node) { if (state != null) { throw new IllegalArgumentException("Comparison cannot be done within now expression"); } if (!hasNow(node)) { return; } state = new BuildState(); node.getLHS().accept(this); node.getRHS().accept(this); if (!">".equals(node.getOperator())) { throw new IllegalArgumentException("Comparison operator '" + node.getOperator() + "' is not supported"); } if (!(node.getLHS() instanceof AttributeNode)) { throw new IllegalArgumentException("Left hand side of comparison must be a document field"); } state.comparison = node; if (state.attribute != null && state.comparison != null && (state.arithmetic != null || state.now != null)) { NowQueryExpression expression = new NowQueryExpression(state.attribute, state.comparison, state.arithmetic); expressionMap.put(expression.getDocumentType(), expression); state = null; } }