package org.zwobble.mammoth.internal.styles; import org.zwobble.mammoth.internal.html.HtmlNode; import java.util.List; import java.util.Map; import static org.zwobble.mammoth.internal.util.MammothLists.list; import static org.zwobble.mammoth.internal.util.MammothLists.reversed; import static org.zwobble.mammoth.internal.util.MammothMaps.map; public class HtmlPath { public static final HtmlPath EMPTY = new HtmlPath(list()); public static HtmlPath element(String tagName) { return element(tagName, map()); } public static HtmlPath element(String tagName, Map attributes) { return new HtmlPath(list(new HtmlPathElement(list(tagName), attributes, false))); } public static HtmlPath collapsibleElement(String tagName) { return collapsibleElement(tagName, map()); } public static HtmlPath collapsibleElement(List tagNames) { return collapsibleElement(tagNames, map()); } public static HtmlPath collapsibleElement(String tagName, Map attributes) { return collapsibleElement(list(tagName), attributes); } public static HtmlPath collapsibleElement(List tagNames, Map attributes) { return new HtmlPath(list(new HtmlPathElement(tagNames, attributes, true))); } private final List elements; public HtmlPath(List elements) { this.elements = elements; } public List wrap(List nodes) { for (HtmlPathElement element : reversed(elements)) { nodes = element.wrap(nodes); } return nodes; } }