1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.devacfr.maven.skins.reflow.snippet;
20
21 import com.google.common.base.MoreObjects;
22 import org.jsoup.nodes.Element;
23
24
25
26
27
28 public class ComponentToken {
29
30
31
32
33
34 public enum Tag {
35
36 empty,
37
38 start,
39
40 end,
41
42 html
43 }
44
45
46
47
48
49
50
51 public enum Type {
52
53 webComponent,
54
55 shortcode
56 }
57
58
59 private final Element element;
60
61
62 private final Tag tag;
63
64
65 private final Type type;
66
67
68 private final String name;
69
70
71
72
73
74 public ComponentToken(final Element element, final String name, final Tag tag, final Type type) {
75 this.element = element;
76 this.name = name;
77 this.tag = tag;
78 this.type = type;
79 }
80
81 public Element getElement() {
82 return element;
83 }
84
85 public String name() {
86 return name;
87 }
88
89 public Type type() {
90 return type;
91 }
92
93 public Tag tag() {
94 return tag;
95 }
96
97 public boolean isCloseTagOf(final ComponentToken startElement) {
98 return name.equals(startElement.name) && type.equals(startElement.type) && Tag.start.equals(startElement.tag)
99 && Tag.end.equals(tag);
100 }
101
102
103
104
105 @Override
106 public String toString() {
107 return MoreObjects.toStringHelper(this).add("name", name).add("type", type).add("tag", tag).toString();
108 }
109 }