@@ -109,36 +109,38 @@ public static Predicate<Value> isListContainingOnly(Type collectionType, Type re
109
109
return isList .and (containsOnlyRequiredType );
110
110
}
111
111
112
- static Collection <Relationship > extractRelationships (Type collectionType , Value entry ) {
112
+ static Collection <Relationship > extractRelationshipsFromCollection (Type collectionType , Value entry ) {
113
113
114
114
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 ());
120
121
}
121
- } else {
122
- relationships .add (listEntry .asRelationship ());
123
122
}
123
+ } else {
124
+ relationships .add (entry .asRelationship ());
124
125
}
125
126
return relationships ;
126
127
}
127
128
128
- static Collection <Node > extractNodes (Type collectionType , Value entry ) {
129
+ static Collection <Node > extractNodesFromCollection (Type collectionType , Value entry ) {
129
130
130
131
// 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.
132
133
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 ());
138
140
}
139
- } else {
140
- nodes .add (listEntry .asNode ());
141
141
}
142
+ } else {
143
+ nodes .add (entry .asNode ());
142
144
}
143
145
return nodes ;
144
146
}
0 commit comments