@Test public void additive() throws Exception { Expression expression = parseExpression("5 add 5"); assertEquals("{5 ADD 5}", expression.toString()); expression = parseExpression("5 sub 5.1"); assertEquals("{5 SUB 5.1}", expression.toString()); expression = parseExpression("2000-02-29 sub 2016-02-29"); assertEquals("{2000-02-29 SUB 2016-02-29}", expression.toString()); expression = parseExpression("2000-02-29T00:00:00Z sub 2016-02-29T01:02:03Z"); assertEquals("{2000-02-29T00:00:00Z SUB 2016-02-29T01:02:03Z}", expression.toString()); expression = parseExpression("duration'PT1H' add duration'PT1M'"); assertEquals("{duration'PT1H' ADD duration'PT1M'}", expression.toString()); expression = parseExpression("2016-01-01 add duration'P60D'"); assertEquals("{2016-01-01 ADD duration'P60D'}", expression.toString()); expression = parseExpression("2000-02-29T00:00:00Z add duration'PT12H'"); assertEquals("{2000-02-29T00:00:00Z ADD duration'PT12H'}", expression.toString()); assertEquals("{1 ADD null}", parseExpression("1 add null").toString()); assertEquals("{null ADD 2}", parseExpression("null add 2").toString()); assertEquals("{null SUB null}", parseExpression("null sub null").toString()); wrongExpression("1 add '2'"); wrongExpression("'1' add 2"); wrongExpression("1 add 2000-02-29"); wrongExpression("11:12:13 sub 2000-02-29T11:12:13Z"); wrongExpression("2000-02-29 add 2016-02-29"); wrongExpression("2000-02-29T00:00:00Z add 2016-02-29T01:02:03Z"); wrongExpression("2000-02-29T00:00:00Z add 1"); wrongExpression("2000-02-29 sub 1"); wrongExpression("duration'P7D' add 2000-02-29"); }
private Expression parseExpression() throws UriParserException, UriValidationException { Expression left = parseAnd(); while (tokenizer.next(TokenKind.OrOperator)) { checkType(left, EdmPrimitiveTypeKind.Boolean); checkNoCollection(left); final Expression right = parseAnd(); checkType(right, EdmPrimitiveTypeKind.Boolean); checkNoCollection(right); left = new BinaryImpl(left, BinaryOperatorKind.OR, right, odata.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Boolean)); } return left; }
ExpressionParser { private Expression parseExpression() throws UriParserException, UriValidationException { Expression left = parseAnd(); while (tokenizer.next(TokenKind.OrOperator)) { checkType(left, EdmPrimitiveTypeKind.Boolean); checkNoCollection(left); final Expression right = parseAnd(); checkType(right, EdmPrimitiveTypeKind.Boolean); checkNoCollection(right); left = new BinaryImpl(left, BinaryOperatorKind.OR, right, odata.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Boolean)); } return left; } }
ExpressionParser { private Expression parseExpression() throws UriParserException, UriValidationException { Expression left = parseAnd(); while (tokenizer.next(TokenKind.OrOperator)) { checkType(left, EdmPrimitiveTypeKind.Boolean); checkNoCollection(left); final Expression right = parseAnd(); checkType(right, EdmPrimitiveTypeKind.Boolean); checkNoCollection(right); left = new BinaryImpl(left, BinaryOperatorKind.OR, right, odata.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Boolean)); } return left; } ExpressionParser(final Edm edm, final OData odata); }
ExpressionParser { private Expression parseExpression() throws UriParserException, UriValidationException { Expression left = parseAnd(); while (tokenizer.next(TokenKind.OrOperator)) { checkType(left, EdmPrimitiveTypeKind.Boolean); checkNoCollection(left); final Expression right = parseAnd(); checkType(right, EdmPrimitiveTypeKind.Boolean); checkNoCollection(right); left = new BinaryImpl(left, BinaryOperatorKind.OR, right, odata.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Boolean)); } return left; } ExpressionParser(final Edm edm, final OData odata); Expression parse(UriTokenizer tokenizer, final EdmType referringType,
      final Collection<String> crossjoinEntitySetNames, final Map<String, AliasQueryOption> aliases); }
ExpressionParser { private Expression parseExpression() throws UriParserException, UriValidationException { Expression left = parseAnd(); while (tokenizer.next(TokenKind.OrOperator)) { checkType(left, EdmPrimitiveTypeKind.Boolean); checkNoCollection(left); final Expression right = parseAnd(); checkType(right, EdmPrimitiveTypeKind.Boolean); checkNoCollection(right); left = new BinaryImpl(left, BinaryOperatorKind.OR, right, odata.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Boolean)); } return left; } ExpressionParser(final Edm edm, final OData odata); Expression parse(UriTokenizer tokenizer, final EdmType referringType,
      final Collection<String> crossjoinEntitySetNames, final Map<String, AliasQueryOption> aliases);  }