1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.river.tool.classdepend;
19
20 import java.util.ArrayList;
21 import java.util.Arrays;
22 import java.util.List;
23
24
25
26
27
28
29
30
31
32
33
34
35
36 public class ClassDependParameters {
37
38
39
40 private final String[] outsidePackagesOrClasses;
41 private final String[] insidePackages;
42 private final String[] showPackages;
43 private final String[] hidePackages;
44 private final boolean ignoreOuterParentClass;
45 private final boolean excludePlatformClasses;
46 private final boolean edges;
47
48 private ClassDependParameters(CDPBuilder builder) {
49
50 outsidePackagesOrClasses = (String[]) builder.outsidePackagesOrClasses.toArray(
51 new String[builder.outsidePackagesOrClasses.size()]);
52 insidePackages = (String[]) builder.insidePackages.toArray(
53 new String[builder.insidePackages.size()]);
54 showPackages = (String[]) builder.showPackages.toArray(
55 new String[builder.showPackages.size()]);
56 hidePackages = (String[]) builder.hidePackages.toArray(
57 new String[builder.hidePackages.size()]);
58 ignoreOuterParentClass = builder.ignoreOuterParentClass;
59 excludePlatformClasses = builder.excludePlatformClasses;
60 edges = builder.edges;
61
62 }
63
64 private List cloneArraytoList(String[] array) {
65
66
67
68
69
70 String[] ac = (String[]) array.clone();
71 return Arrays.asList(ac);
72
73 }
74
75
76
77
78
79
80
81
82 public List outsidePackagesOrClasses() {
83 return cloneArraytoList(outsidePackagesOrClasses);
84 }
85
86 public List insidePackages() {
87 return cloneArraytoList(insidePackages);
88 }
89
90 public List showPackages() {
91 return cloneArraytoList(showPackages);
92 }
93
94 public List hidePackages() {
95 return cloneArraytoList(hidePackages);
96 }
97
98 public boolean ignoreOuterParentClass() {
99 return ignoreOuterParentClass;
100 }
101
102 public boolean excludePlatformClasses() {
103 return excludePlatformClasses;
104 }
105
106 public boolean edges() {
107 return edges;
108 }
109
110
111
112
113
114
115
116
117
118
119
120
121
122 public static class CDPBuilder {
123
124
125
126
127 private List outsidePackagesOrClasses = new ArrayList();
128 private List insidePackages = new ArrayList();
129 private List showPackages = new ArrayList();
130 private List hidePackages = new ArrayList();
131 private boolean ignoreOuterParentClass = false;
132 private boolean excludePlatformClasses = false;
133 private boolean edges = false;
134
135 public CDPBuilder() {
136 }
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151 public CDPBuilder addOutsidePackageOrClass(String outsidePackageOrClass) {
152 outsidePackagesOrClasses.add(outsidePackageOrClass);
153 return this;
154 }
155
156 public CDPBuilder addOutsidePackagesOrClasses(String[] outsidePackagesOrClasses) {
157 int l = outsidePackagesOrClasses.length;
158 for (int i = 0; i < l; i++) {
159 this.outsidePackagesOrClasses.add(outsidePackagesOrClasses[i]);
160 }
161 return this;
162 }
163
164 public CDPBuilder addOutsidePackagesOrClasses(List excludes) {
165 outsidePackagesOrClasses.addAll(excludes);
166 return this;
167 }
168
169
170
171
172
173
174
175
176
177
178
179
180 public CDPBuilder addInsidePackage(String insidePackage) {
181 insidePackages.add(insidePackage);
182 return this;
183 }
184
185
186
187
188
189
190
191 public CDPBuilder addInsidePackages(String[] insidePackages) {
192 for (int i = 0, l = insidePackages.length; i < l; i++) {
193 this.insidePackages.add(insidePackages[i]);
194 }
195 return this;
196 }
197
198 public CDPBuilder addInsidePackages(List inside) {
199 insidePackages.addAll(inside);
200 return this;
201 }
202
203 public CDPBuilder addShowPackages(String [] showPackages){
204 for (int i = 0, l = showPackages.length; i < l; i++){
205 this.showPackages.add(showPackages[i]);
206 }
207 return this;
208 }
209
210 public CDPBuilder addShowPackages(List showPackages){
211 this.showPackages.addAll(showPackages);
212 return this;
213 }
214
215 public CDPBuilder addShowPackage(String showPackage){
216 this.showPackages.add(showPackage);
217 return this;
218 }
219
220 public CDPBuilder addHidePackages(String [] hidePackages){
221 for (int i = 0, l = hidePackages.length; i < l; i++){
222 this.hidePackages.add(hidePackages[i]);
223 }
224 return this;
225 }
226
227 public CDPBuilder addHidePackages(List hidePackages){
228 this.hidePackages.addAll(hidePackages);
229 return this;
230 }
231
232 public CDPBuilder addHidePackage(String hidePackage){
233 this.hidePackages.add(hidePackage);
234 return this;
235 }
236
237 public CDPBuilder ignoreOuterParentClass(boolean b) {
238 ignoreOuterParentClass = b;
239 return this;
240 }
241
242
243
244
245
246
247
248
249
250
251
252
253 public CDPBuilder excludePlatformClasses(boolean b) {
254 excludePlatformClasses = b;
255 return this;
256 }
257
258 public CDPBuilder edges(boolean e){
259 edges = e;
260 return this;
261 }
262
263
264
265
266
267
268
269
270 public ClassDependParameters build() {
271 return new ClassDependParameters(this);
272 }
273 }
274 }