blob: 7dbba822f8bcd96776abfc8542168320b0dc25b1 (
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
|
package org.zwobble.mammoth.internal.styles;
import org.zwobble.mammoth.internal.documents.Table;
import java.util.Optional;
public class TableMatcher implements DocumentElementMatcher<Table> {
public static final TableMatcher ANY = new TableMatcher(Optional.empty(), Optional.empty());
public static TableMatcher styleId(String styleId) {
return new TableMatcher(Optional.of(styleId), Optional.empty());
}
public static TableMatcher styleName(String styleName) {
return new TableMatcher(Optional.empty(), Optional.of(new EqualToStringMatcher(styleName)));
}
private final Optional<String> styleId;
private final Optional<StringMatcher> styleName;
public TableMatcher(Optional<String> styleId, Optional<StringMatcher> styleName) {
this.styleId = styleId;
this.styleName = styleName;
}
@Override
public boolean matches(Table table) {
return DocumentElementMatching.matchesStyle(styleId, styleName, table.getStyle());
}
}
|