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 underline; private Optional strikethrough; private Optional bold; private Optional italic; private final ImmutableList.Builder> paragraphStyles = ImmutableList.builder(); private final ImmutableList.Builder> runStyles = ImmutableList.builder(); public StyleMapBuilder() { this.bold = Optional.empty(); this.underline = Optional.empty(); this.strikethrough = Optional.empty(); this.italic = Optional.empty(); } public StyleMapBuilder bold(HtmlPath path) { this.bold = Optional.of(path); return this; } public StyleMapBuilder italic(HtmlPath path) { this.italic = Optional.of(path); return this; } 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(matcher, path)); return this; } public StyleMapBuilder mapRun(RunMatcher matcher, HtmlPath path) { runStyles.add(new StyleMapping(matcher, path)); return this; } public StyleMap build() { return new StyleMap(bold, italic, underline, strikethrough, paragraphStyles.build(), runStyles.build()); } }