@Test public void testNestedExpressions(){ Option<String> source = AttributeCompiler.translateToJavaGetter("(3 + (2)) - 10/5"); assertEquals("((3+2)-(10/5))", source.get()); assertEquals((3 + (2)) - 10/5, ((3+2)-(10/5))); source = AttributeCompiler.translateToJavaGetter("(3 - (2)) - 10/5"); assertEquals("((3-2)-(10/5))", source.get()); assertEquals((3 - (2)) - 10/5, ((3-2)-(10/5))); source = AttributeCompiler.translateToJavaGetter("(3 - (2+7)) - 10/5"); assertEquals("((3-(2+7))-(10/5))", source.get()); assertEquals((3 - (2+7)) - 10/5, ((3-(2+7))-(10/5))); assertEquals(-8, ((3-(2+7))-(10/5))); source = AttributeCompiler.translateToJavaGetter("(3 - (2+7)) - 10/(5-3)"); assertEquals("((3-(2+7))-(10/(5-3)))", source.get()); assertEquals((3 - (2+7)) - 10/(5-3), ((3-(2+7))-(10/(5-3)))); source = AttributeCompiler.translateToJavaGetter("(modelName.num - (2*(7-1))) - 10/(modelName.num-3)"); assertEquals("((scope.modelName.getNum()-(2*(7-1)))-(10/(scope.modelName.getNum()-3)))", source.get()); }
public static Option<String> translateToJavaGetter(String source) { Option<Node> expression = Parser.tryParse(source); if (expression.isAbsent()) { return Option.absent(); } else { return Option.of(GetExpressionVisitor.generateGetExpression(expression.get(), "", "")); } }
AttributeCompiler { public static Option<String> translateToJavaGetter(String source) { Option<Node> expression = Parser.tryParse(source); if (expression.isAbsent()) { return Option.absent(); } else { return Option.of(GetExpressionVisitor.generateGetExpression(expression.get(), "", "")); } } }
AttributeCompiler { public static Option<String> translateToJavaGetter(String source) { Option<Node> expression = Parser.tryParse(source); if (expression.isAbsent()) { return Option.absent(); } else { return Option.of(GetExpressionVisitor.generateGetExpression(expression.get(), "", "")); } } @Inject  AttributeCompiler(); }
AttributeCompiler { public static Option<String> translateToJavaGetter(String source) { Option<Node> expression = Parser.tryParse(source); if (expression.isAbsent()) { return Option.absent(); } else { return Option.of(GetExpressionVisitor.generateGetExpression(expression.get(), "", "")); } } @Inject  AttributeCompiler(); static Option<String> translateToJavaGetter(String source); static Option<String> translateToJavaSetter(String source, String value); }
AttributeCompiler { public static Option<String> translateToJavaGetter(String source) { Option<Node> expression = Parser.tryParse(source); if (expression.isAbsent()) { return Option.absent(); } else { return Option.of(GetExpressionVisitor.generateGetExpression(expression.get(), "", "")); } } @Inject  AttributeCompiler(); static Option<String> translateToJavaGetter(String source); static Option<String> translateToJavaSetter(String source, String value);  }