public static <T> void setupAttributes(Element orderEntry,
                                         Function<? super T, String> fun,
                                         String attributeName,
                                         T[] roots) {
    final List<String> eclipseUrls = new ArrayList<>();
    if (roots.length > 0) {
      eclipseUrls.add(fun.fun(roots[0]));
    }

    final List<Element> children = new ArrayList<>(orderEntry.getChildren(ATTRIBUTES_TAG));
    for (Element attsElement : children) {
      final ArrayList<Element> attTags = new ArrayList<>(attsElement.getChildren(ATTRIBUTE_TAG));
      for (Element attElement : attTags) {
        if (Comparing.strEqual(attElement.getAttributeValue("name"), attributeName)) {
          final String javadocPath = attElement.getAttributeValue("value");
          if (!eclipseUrls.remove(javadocPath)) {
            attElement.detach();
          }
        }
      }
    }

    for (final String docUrl : eclipseUrls) {
      Element child = orderEntry.getChild(ATTRIBUTES_TAG);
      if (child == null) {
        child = new Element(ATTRIBUTES_TAG);
        orderEntry.addContent(child);
      }

      final Element attrElement = new Element(ATTRIBUTE_TAG);
      child.addContent(attrElement);
      attrElement.setAttribute("name", attributeName);
      attrElement.setAttribute("value", docUrl);
    }
  }
public static <T> void setupAttributes(Element orderEntry,
                                         Function<? super T, String> fun,
                                         String attributeName,
                                         T[] roots)