Exemplo n.º 1
0
  public void normalize() {
    if (hasChildren()) {
      Map<String, DebugValueMap> occurred = new HashMap<>();
      for (DebugValueMap map : children) {
        String mapName = map.getName();
        if (!occurred.containsKey(mapName)) {
          occurred.put(mapName, map);
          map.normalize();
        } else {
          occurred.get(mapName).mergeWith(map);
          occurred.get(mapName).normalize();
        }
      }

      if (occurred.values().size() < children.size()) {
        // At least one duplicate was found.
        children.clear();
        for (DebugValueMap map : occurred.values()) {
          addChild(map);
          map.normalize();
        }
      }
    }
  }