blob: ae7140eb28df4a26e1276d18068ca85dc2fedd17 (
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.internal.styles;
import com.google.common.collect.ImmutableList;
import org.zwobble.mammoth.internal.documents.Paragraph;
import org.zwobble.mammoth.internal.documents.Run;
import java.util.Optional;
public class StyleMapBuilder {
private Optional<HtmlPath> underline;
private Optional<HtmlPath> strikethrough;
private final ImmutableList.Builder<StyleMapping<Paragraph>> paragraphStyles = ImmutableList.builder();
private final ImmutableList.Builder<StyleMapping<Run>> runStyles = ImmutableList.builder();
public StyleMapBuilder() {
this.underline = Optional.empty();
this.strikethrough = Optional.empty();
}
public StyleMapBuilder underline(HtmlPath path) {
this.underline = Optional.of(path);
return this;
}
public StyleMapBuilder strikethrough(HtmlPath path) {
this.strikethrough = Optional.of(path);
return this;
}
public StyleMapBuilder mapParagraph(ParagraphMatcher matcher, HtmlPath path) {
paragraphStyles.add(new StyleMapping<Paragraph>(matcher, path));
return this;
}
public StyleMapBuilder mapRun(RunMatcher matcher, HtmlPath path) {
runStyles.add(new StyleMapping<Run>(matcher, path));
return this;
}
public StyleMap build() {
return new StyleMap(underline, strikethrough, paragraphStyles.build(), runStyles.build());
}
}
|