@Test public void testStringAdditionCompilation(){ Option<String> getter = AttributeCompiler.translateToJavaGetter("getStringValue() + 'orange ' + getIntValue()"); assertEquals("((scope.getStringValue()+\"orange \")+scope.getIntValue())", getter.get()); getter = AttributeCompiler.translateToJavaGetter("isTrue() ? 'abcdefg ' + getIntValue() : getStringValue()"); assertEquals("(scope.isTrue())?((\"abcdefg \"+scope.getIntValue())):(scope.getStringValue())", getter.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);  }