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
44
45
46
47
48
49
50
51
52
53
|
package org.zwobble.mammoth.internal.documents;
import java.util.List;
import java.util.Optional;
public class Hyperlink implements DocumentElement, HasChildren<Hyperlink> {
public static Hyperlink href(String href, Optional<String> targetFrame, List<DocumentElement> children) {
return new Hyperlink(Optional.of(href), Optional.empty(), targetFrame, children);
}
public static Hyperlink anchor(String anchor, Optional<String> targetFrame, List<DocumentElement> children) {
return new Hyperlink(Optional.empty(), Optional.of(anchor), targetFrame, children);
}
private final Optional<String> href;
private final Optional<String> anchor;
private final Optional<String> targetFrame;
private final List<DocumentElement> children;
public Hyperlink(Optional<String> href, Optional<String> anchor, Optional<String> targetFrame, List<DocumentElement> children) {
this.href = href;
this.anchor = anchor;
this.targetFrame = targetFrame;
this.children = children;
}
public Optional<String> getHref() {
return href;
}
public Optional<String> getAnchor() {
return anchor;
}
public Optional<String> getTargetFrame() {
return targetFrame;
}
@Override
public List<DocumentElement> getChildren() {
return children;
}
@Override
public Hyperlink replaceChildren(List<DocumentElement> newChildren) {
return new Hyperlink(this.href, this.anchor, this.targetFrame, newChildren);
}
@Override
public <T, U> T accept(DocumentElementVisitor<T, U> visitor, U context) {
return visitor.visit(this, context);
}
}
|