protected Node visitNullIfExpression(final NullIfExpression node, final Object context) { // use an if/else block here (instead of isPresent.map(...).orElse(...)) so only one object // gets instantiated (issue #1784) if (node.getLocation().isPresent()) { return new NullIfExpression(node.getLocation().get(), (Expression) process(node.getFirst(), context), (Expression) process(node.getSecond(), context)); } else { return new NullIfExpression((Expression) process(node.getFirst(), context), (Expression) process(node.getSecond(), context)); } }
@Test public void shouldFormatNullIfExpression() { assertThat(ExpressionFormatter.formatExpression(new NullIfExpression( new StringLiteral("first"), new StringLiteral("second"))), equalTo("NULLIF('first', 'second')")); }