in scim-core/src/main/java/org/apache/directory/scim/core/repository/UpdateRequest.java [185:215]
private static void nullEmptyLists(JsonNode node) {
List<String> objectsToDelete = new ArrayList<>();
if (node != null) {
Iterator<Map.Entry<String, JsonNode>> children = node.fields();
while(children.hasNext()) {
Map.Entry<String, JsonNode> child = children.next();
String name = child.getKey();
JsonNode childNode = child.getValue();
//Attempt to delete children before analyzing
if (childNode.isContainerNode()) {
nullEmptyLists(childNode);
}
if (childNode instanceof ArrayNode) {
ArrayNode ar = (ArrayNode)childNode;
if (ar.size() == 0) {
objectsToDelete.add(name);
}
}
}
if (!objectsToDelete.isEmpty() && node instanceof ObjectNode) {
ObjectNode on = (ObjectNode)node;
for(String name : objectsToDelete) {
on.remove(name);
}
}
}
}