1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package com.puppycrawl.tools.checkstyle.checks.javadoc;
21
22 import java.util.Objects;
23 import java.util.Optional;
24
25 import com.puppycrawl.tools.checkstyle.api.DetailNode;
26 import com.puppycrawl.tools.checkstyle.utils.JavadocUtil;
27 import com.puppycrawl.tools.checkstyle.utils.UnmodifiableCollectionUtil;
28
29
30
31
32
33 public class JavadocNodeImpl implements DetailNode {
34
35
36
37
38 public static final JavadocNodeImpl[] EMPTY_DETAIL_NODE_ARRAY = new JavadocNodeImpl[0];
39
40
41
42
43 private int index;
44
45
46
47
48 private int type;
49
50
51
52
53 private String text;
54
55
56
57
58 private int lineNumber;
59
60
61
62
63 private int columnNumber;
64
65
66
67
68 private DetailNode[] children;
69
70
71
72
73 private DetailNode parent;
74
75 @Override
76 public int getType() {
77 return type;
78 }
79
80 @Override
81 public String getText() {
82 return text;
83 }
84
85 @Override
86 public int getLineNumber() {
87 return lineNumber;
88 }
89
90 @Override
91 public int getColumnNumber() {
92 return columnNumber;
93 }
94
95 @Override
96 public DetailNode[] getChildren() {
97 return Optional.ofNullable(children)
98 .map(array -> UnmodifiableCollectionUtil.copyOfArray(array, array.length))
99 .orElse(EMPTY_DETAIL_NODE_ARRAY);
100 }
101
102 @Override
103 public DetailNode getParent() {
104 return parent;
105 }
106
107 @Override
108 public int getIndex() {
109 return index;
110 }
111
112
113
114
115
116
117 public void setType(int type) {
118 this.type = type;
119 }
120
121
122
123
124
125
126 public void setText(String text) {
127 this.text = text;
128 }
129
130
131
132
133
134
135 public void setLineNumber(int lineNumber) {
136 this.lineNumber = lineNumber;
137 }
138
139
140
141
142
143
144 public void setColumnNumber(int columnNumber) {
145 this.columnNumber = columnNumber;
146 }
147
148
149
150
151
152
153 public void setChildren(DetailNode... children) {
154 this.children = UnmodifiableCollectionUtil.copyOfArray(children, children.length);
155 }
156
157
158
159
160
161
162 public void setParent(DetailNode parent) {
163 this.parent = parent;
164 }
165
166
167
168
169
170
171 public void setIndex(int index) {
172 this.index = index;
173 }
174
175 @Override
176 public String toString() {
177 return "JavadocNodeImpl["
178 + "index=" + index
179 + ", type=" + JavadocUtil.getTokenName(type)
180 + ", text='" + text + '\''
181 + ", lineNumber=" + lineNumber
182 + ", columnNumber=" + columnNumber
183 + ", children=" + Objects.hashCode(children)
184 + ", parent=" + parent + ']';
185 }
186
187 }