From d91fdcbe5ff3a09d6b8f444a563dd6135e14c9e6 Mon Sep 17 00:00:00 2001 From: "Benjamin, Max" Date: Fri, 16 Aug 2019 10:59:18 -0400 Subject: fixed dsl builder to correctly add output fixed dsl builder to correctly add output look for lambda key rather than parent class null Issue-ID: SO-2233 Signed-off-by: Benjamin, Max (mb388a) Change-Id: I251b9b8b4c391354b9759ee16a2462df43c188f9 --- .../graphinventory/entities/DSLQueryBuilder.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'common/src/main/java/org/onap') diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/DSLQueryBuilder.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/DSLQueryBuilder.java index ffbb86f023..ad3bb6c311 100644 --- a/common/src/main/java/org/onap/so/client/graphinventory/entities/DSLQueryBuilder.java +++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/DSLQueryBuilder.java @@ -20,6 +20,7 @@ package org.onap.so.client.graphinventory.entities; +import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -49,8 +50,24 @@ public class DSLQueryBuilder implements QueryStep { } public DSLQueryBuilder output() { - if (steps.get(steps.size() - 1) instanceof DSLNode) { + Object obj = steps.get(steps.size() - 1); + if (obj instanceof DSLNode) { ((DSLNode) steps.get(steps.size() - 1)).output(); + } else if (obj.getClass().getName().contains("$$Lambda$")) { + // process lambda expressions + for (Field f : obj.getClass().getDeclaredFields()) { + f.setAccessible(true); + Object o; + try { + o = f.get(obj); + if (o instanceof DSLQueryBuilder && ((DSLQueryBuilder) o).steps.get(0) instanceof DSLNode) { + ((DSLNode) ((DSLQueryBuilder) o).steps.get(0)).output(); + } + } catch (IllegalArgumentException | IllegalAccessException e) { + } + f.setAccessible(false); + break; + } } return this; } -- cgit 1.2.3-korg