blob: 9b2b92098306ed91b36f72d47d8f397a220aa7ba (
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
|
package org.zwobble.mammoth.documents;
import java.util.List;
import java.util.Optional;
public class Hyperlink implements DocumentElement, HasChildren {
public static Hyperlink href(String href, List<DocumentElement> children) {
return new Hyperlink(Optional.of(href), Optional.empty(), children);
}
public static Hyperlink anchor(String anchor, List<DocumentElement> children) {
return new Hyperlink(Optional.empty(), Optional.of(anchor), children);
}
private final Optional<String> href;
private final Optional<String> anchor;
private final List<DocumentElement> children;
private Hyperlink(Optional<String> href, Optional<String> anchor, List<DocumentElement> children) {
this.href = href;
this.anchor = anchor;
this.children = children;
}
public Optional<String> getHref() {
return href;
}
public Optional<String> getAnchor() {
return anchor;
}
@Override
public List<DocumentElement> getChildren() {
return children;
}
@Override
public <T> T accept(DocumentElementVisitor<T> visitor) {
return visitor.visit(this);
}
}
|