aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/zwobble/mammoth/styles/HtmlPathElement.java
blob: b34fb50941c65830cb37931314a9982b2f1a758b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package org.zwobble.mammoth.styles;

import org.zwobble.mammoth.html.HtmlElement;
import org.zwobble.mammoth.html.HtmlNode;

import java.util.List;
import java.util.Map;

import static org.zwobble.mammoth.util.MammothLists.list;
import static org.zwobble.mammoth.util.MammothMaps.map;

public class HtmlPathElement {
    public static HtmlPathElement fresh(String tagName) {
        return new HtmlPathElement(tagName, map(), false);
    }

    public static HtmlPathElement collapsible(String tagName) {
        return new HtmlPathElement(tagName, map(), true);
    }

    private final String tagName;
    private final Map<String, String> attributes;
    private final boolean isCollapsible;

    public HtmlPathElement(String tagName, Map<String, String> attributes, boolean isCollapsible) {
        this.tagName = tagName;
        this.attributes = attributes;
        this.isCollapsible = isCollapsible;
    }

    public List<HtmlNode> wrap(List<HtmlNode> nodes) {
        return list(new HtmlElement(tagName, attributes, nodes, isCollapsible));
    }
}