aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/zwobble/mammoth/styles/StyleMapBuilder.java
blob: c815e1bef6c22b967deefc33e9079420b031b021 (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
35
36
37
38
39
40
41
42
43
package org.zwobble.mammoth.styles;

import com.google.common.collect.ImmutableMap;

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

public class StyleMapBuilder {
    private HtmlPath underline;
    private HtmlPath strikethrough;
    private final ImmutableMap.Builder<String, HtmlPath> paragraphStyles = ImmutableMap.builder();

    public StyleMapBuilder() {
        this.underline = new HtmlPath(list());
        this.strikethrough = new HtmlPath(list(HtmlPath.collapsibleElement("s")));
    }

    public StyleMapBuilder underline(HtmlPathElement element) {
        return underline(new HtmlPath(list(element)));
    }

    public StyleMapBuilder underline(HtmlPath path) {
        this.underline = path;
        return this;
    }

    public StyleMapBuilder strikethrough(HtmlPathElement element) {
        return strikethrough(new HtmlPath(list(element)));
    }

    public StyleMapBuilder strikethrough(HtmlPath path) {
        this.strikethrough = path;
        return this;
    }

    public StyleMapBuilder mapParagraph(String styleId, HtmlPath path) {
        paragraphStyles.put(styleId, path);
        return this;
    }

    public StyleMap build() {
        return new StyleMap(underline, strikethrough, paragraphStyles.build());
    }
}