@Test public void testStringCompilation(){ assertEquals("\"Martin Luther King Jr.\"", AttributeCompiler.translateToJavaGetter("'Martin Luther King Jr.'").get()); Option<String> getter = AttributeCompiler.translateToJavaGetter("xyz('Martin Luther King Jr.')"); assertEquals("scope.xyz(\"Martin Luther King Jr.\")", getter.get()); getter = AttributeCompiler.translateToJavaGetter("xyz('Martin Luther King\\'s Jr.')"); assertEquals("scope.xyz(\"Martin Luther King\\'s Jr.\")", getter.get()); getter = AttributeCompiler.translateToJavaGetter("xyz('Martin \"Luther\" King\\'s Jr.')"); assertEquals("scope.xyz(\"Martin \\\"Luther\\\" King\\'s Jr.\")", 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);  }