public static Expression getKey(Expression currentContext, CompositeType contextType, String key) { if (contextType instanceof MapBackedType) { EnclosedExpr enclosedExpr = Expressions.castTo(MapT, currentContext); return new MethodCallExpr(enclosedExpr, "get") .addArgument(new StringLiteralExpr(key)); } else if (contextType instanceof JavaBackedType) { JavaBackedType javaBackedType = (JavaBackedType) contextType; Class<?> wrappedType = javaBackedType.getWrapped(); Method accessor = EvalHelper.getGenericAccessor(wrappedType, key); Type type = JavaParser.parseType(wrappedType.getCanonicalName()); return new MethodCallExpr(Expressions.castTo(type, currentContext), accessor.getName()); } else { throw new UnsupportedOperationException("A Composite type is either MapBacked or JavaBAcked"); } } }
} else if (compositeType instanceof JavaBackedType) { JavaBackedType javaBackedType = (JavaBackedType) compositeType; Method accessor = EvalHelper.getGenericAccessor(javaBackedType.getWrapped(), accText); CastExpr castExpr = new CastExpr(JavaParser.parseType(javaBackedType.getWrapped().getCanonicalName()), exprCursor); EnclosedExpr enclosedExpr = new EnclosedExpr(castExpr);
Method getter = getGenericAccessor( current.getClass(), property ); if ( getter != null ) { try {