Github user chinmaykolhatkar commented on a diff in the pull request:
https://github.com/apache/incubator-apex-malhar/pull/209#discussion_r56785681
--- Diff: library/src/main/java/com/datatorrent/lib/util/PojoUtils.java ---
@@ -572,41 +573,13 @@ private static String
getSingleFieldGetterExpression(final Class<?> pojoClass, f
@SuppressWarnings("StringEquality")
private static Object createGetter(Class<?> pojoClass, String
getterExpr, String exprObjectPlaceholder, Class<?> exprClass, Class<?>
getterClass)
{
- if (getterExpr.startsWith(".")) {
- getterExpr = getterExpr.substring(1);
- }
-
- if (getterExpr.isEmpty()) {
- throw new IllegalArgumentException("The getter expression: \"" +
getterExpr + "\" is invalid.");
- }
-
logger.debug("{} {} {} {}", pojoClass, getterExpr, exprClass,
getterClass);
- IScriptEvaluator se;
-
- try {
- se =
CompilerFactoryFactory.getDefaultCompilerFactory().newScriptEvaluator();
- } catch (Exception ex) {
- throw new RuntimeException(ex);
- }
-
- String code = StringUtils.replaceEach(getterExpr, new
String[]{exprObjectPlaceholder},
- new String[]{new JavaStatement(pojoClass.getName().length() +
OBJECT.length() + 4).appendCastToTypeExpr(pojoClass, OBJECT).toString()});
- if (code != getterExpr) {
- code = new JavaReturnStatement(exprClass.getName().length() +
code.length() + 12, exprClass).append(code).getStatement();
- logger.debug("Original expression {} is a complex expression.
Replacing it with {}.", getterExpr, code);
- }
- else {
- code = getSingleFieldGetterExpression(pojoClass, getterExpr,
exprClass);
- }
-
- logger.debug("code: {}", code);
+ JavaExpressionParser javaExpressionParser = new JavaExpressionParser();
+ javaExpressionParser.setInputObjectPlaceholder("$", PojoUtils.OBJECT);
--- End diff --
Done.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---