Skip to content

Commit

Permalink
replace forEach with while loop for children iterator.
Browse files Browse the repository at this point in the history
  • Loading branch information
wildone committed Jul 15, 2024
1 parent d1d67df commit 0ba5f83
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static org.apache.sling.models.annotations.DefaultInjectionStrategy.OPTIONAL;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import org.apache.sling.api.resource.Resource;
Expand Down Expand Up @@ -92,7 +93,9 @@ protected void init() {
this.fieldId = this.resource.getName();

if (this.resource.hasChildren()) {
this.resource.getChildren().forEach(child -> {
Iterator<Resource> children = this.resource.listChildren();
while (children.hasNext()) {
Resource child = children.next();
String name = child.getName();
if (name.equals("label")) {
String id = child.getValueMap().get("id", "");
Expand All @@ -103,7 +106,7 @@ protected void init() {
this.fieldId = this.resource.getName() + (StringUtils.isNotEmpty(id) ? "-" + id : "");
this.fieldHidden = false;
}
});
}
}

}
Expand Down

0 comments on commit 0ba5f83

Please sign in to comment.