@@ -382,37 +382,32 @@ public JsonNode findValue(String propertyName)
382
382
@ Override
383
383
public List <JsonNode > findValues (String propertyName , List <JsonNode > foundSoFar )
384
384
{
385
- JsonNode jsonNode = _children .get (propertyName );
386
- if (jsonNode != null ) {
387
- if (foundSoFar == null ) {
388
- foundSoFar = new ArrayList <>();
385
+ for (Map .Entry <String , JsonNode > entry : _children .entrySet ()) {
386
+ if (propertyName .equals (entry .getKey ())) {
387
+ if (foundSoFar == null ) {
388
+ foundSoFar = new ArrayList <JsonNode >();
389
+ }
390
+ foundSoFar .add (entry .getValue ());
391
+ } else { // only add children if parent not added
392
+ foundSoFar = entry .getValue ().findValues (propertyName , foundSoFar );
389
393
}
390
- foundSoFar .add (jsonNode );
391
- return foundSoFar ;
392
- }
393
-
394
- // only add children if parent not added
395
- for (JsonNode child : _children .values ()) {
396
- foundSoFar = child .findValues (propertyName , foundSoFar );
397
394
}
398
395
return foundSoFar ;
399
396
}
400
397
401
398
@ Override
402
399
public List <String > findValuesAsText (String propertyName , List <String > foundSoFar )
403
400
{
404
- JsonNode jsonNode = _children .get (propertyName );
405
- if (jsonNode != null ) {
406
- if (foundSoFar == null ) {
407
- foundSoFar = new ArrayList <>();
401
+ for (Map .Entry <String , JsonNode > entry : _children .entrySet ()) {
402
+ if (propertyName .equals (entry .getKey ())) {
403
+ if (foundSoFar == null ) {
404
+ foundSoFar = new ArrayList <String >();
405
+ }
406
+ foundSoFar .add (entry .getValue ().asText ());
407
+ } else { // only add children if parent not added
408
+ foundSoFar = entry .getValue ().findValuesAsText (propertyName ,
409
+ foundSoFar );
408
410
}
409
- foundSoFar .add (jsonNode .asText ());
410
- return foundSoFar ;
411
- }
412
-
413
- // only add children if parent not added
414
- for (JsonNode child : _children .values ()) {
415
- foundSoFar = child .findValuesAsText (propertyName , foundSoFar );
416
411
}
417
412
return foundSoFar ;
418
413
}
@@ -436,18 +431,16 @@ public ObjectNode findParent(String propertyName)
436
431
@ Override
437
432
public List <JsonNode > findParents (String propertyName , List <JsonNode > foundSoFar )
438
433
{
439
- JsonNode jsonNode = _children .get (propertyName );
440
- if (jsonNode != null ) {
441
- if (foundSoFar == null ) {
442
- foundSoFar = new ArrayList <>();
434
+ for (Map .Entry <String , JsonNode > entry : _children .entrySet ()) {
435
+ if (propertyName .equals (entry .getKey ())) {
436
+ if (foundSoFar == null ) {
437
+ foundSoFar = new ArrayList <JsonNode >();
438
+ }
439
+ foundSoFar .add (this );
440
+ } else { // only add children if parent not added
441
+ foundSoFar = entry .getValue ()
442
+ .findParents (propertyName , foundSoFar );
443
443
}
444
- foundSoFar .add (this );
445
- return foundSoFar ;
446
- }
447
-
448
- // only add children if parent not added
449
- for (JsonNode child : _children .values ()) {
450
- foundSoFar = child .findParents (propertyName , foundSoFar );
451
444
}
452
445
return foundSoFar ;
453
446
}
0 commit comments