@@ -109,36 +109,38 @@ public static Predicate<Value> isListContainingOnly(Type collectionType, Type re
109109 return isList .and (containsOnlyRequiredType );
110110 }
111111
112- static Collection <Relationship > extractRelationships (Type collectionType , Value entry ) {
112+ static Collection <Relationship > extractRelationshipsFromCollection (Type collectionType , Value entry ) {
113113
114114 Collection <Relationship > relationships = new HashSet <>();
115-
116- for (Value listEntry : entry .values ()) {
117- if (listEntry .hasType (collectionType )) {
118- for (Value listInListEntry : entry .asList (Function .identity ())) {
119- relationships .addAll (extractRelationships (collectionType , listInListEntry ));
115+ if (entry .hasType (collectionType )) {
116+ for (Value listWithRelationshipsOrRelationship : entry .values ()) {
117+ if (listWithRelationshipsOrRelationship .hasType (collectionType )) {
118+ relationships .addAll (listWithRelationshipsOrRelationship .asList (Value ::asRelationship ));
119+ } else {
120+ relationships .add (listWithRelationshipsOrRelationship .asRelationship ());
120121 }
121- } else {
122- relationships .add (listEntry .asRelationship ());
123122 }
123+ } else {
124+ relationships .add (entry .asRelationship ());
124125 }
125126 return relationships ;
126127 }
127128
128- static Collection <Node > extractNodes (Type collectionType , Value entry ) {
129+ static Collection <Node > extractNodesFromCollection (Type collectionType , Value entry ) {
129130
130131 // There can be multiple relationships leading to the same node.
131- // Thus we need a collection implementation that supports duplicates.
132+ // Thus, we need a collection implementation that supports duplicates.
132133 Collection <Node > nodes = new ArrayList <>();
133-
134- for (Value listEntry : entry .values ()) {
135- if (listEntry .hasType (collectionType )) {
136- for (Value listInListEntry : entry .asList (Function .identity ())) {
137- nodes .addAll (extractNodes (collectionType , listInListEntry ));
134+ if (entry .hasType (collectionType )) {
135+ for (Value listWithNodesOrNode : entry .values ()) {
136+ if (listWithNodesOrNode .hasType (collectionType )) {
137+ nodes .addAll (listWithNodesOrNode .asList (Value ::asNode ));
138+ } else {
139+ nodes .add (listWithNodesOrNode .asNode ());
138140 }
139- } else {
140- nodes .add (listEntry .asNode ());
141141 }
142+ } else {
143+ nodes .add (entry .asNode ());
142144 }
143145 return nodes ;
144146 }
0 commit comments