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; |
20 |
|
|
21 |
|
import javax.annotation.Nonnull; |
22 |
|
import javax.annotation.Nullable; |
23 |
|
|
24 |
|
import java.util.Collections; |
25 |
|
import java.util.List; |
26 |
|
import java.util.stream.Collectors; |
27 |
|
|
28 |
|
import com.google.common.collect.Lists; |
29 |
|
import org.codehaus.plexus.util.xml.Xpp3Dom; |
30 |
|
|
31 |
|
import static java.util.Objects.requireNonNull; |
32 |
|
|
33 |
|
|
34 |
|
@link |
35 |
|
|
36 |
|
@author |
37 |
|
@since |
38 |
|
|
|
|
| 89,2% |
Uncovered Elements: 4 (37) |
Complexity: 10 |
Complexity Density: 0,48 |
|
39 |
|
public final class Xpp3Utils { |
40 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
41 |
0 |
private Xpp3Utils() {... |
42 |
0 |
throw new UnsupportedOperationException(); |
43 |
|
} |
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
@param |
49 |
|
|
50 |
|
@param |
51 |
|
|
52 |
|
@param |
53 |
|
|
54 |
|
@return@link |
55 |
|
|
56 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 3 |
Complexity Density: 0,43 |
|
57 |
602 |
@Nullable public static Xpp3Dom getFirstChild(@Nullable final Xpp3Dom parentNode,... |
58 |
|
@Nonnull final String name, |
59 |
|
@Nonnull final String namespace) { |
60 |
602 |
if (parentNode == null) { |
61 |
33 |
return null; |
62 |
|
} |
63 |
569 |
requireNonNull(namespace); |
64 |
569 |
final Xpp3Dom child = parentNode.getChild(requireNonNull(name)); |
65 |
569 |
if (child != null) { |
66 |
255 |
return child; |
67 |
|
} |
68 |
|
|
69 |
314 |
return parentNode.getChild(namespace + name); |
70 |
|
} |
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
@param |
76 |
|
|
77 |
|
@return@link |
78 |
|
|
79 |
|
@since |
80 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
81 |
2 |
@SuppressWarnings("null")... |
82 |
|
@Nonnull |
83 |
|
public static List<String> getChildren(@Nullable final Xpp3Dom parentNode) { |
84 |
2 |
return getChildrenNodes(parentNode, null).stream().map(Xpp3Dom::getName).collect(Collectors.toList()); |
85 |
|
} |
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
@param |
91 |
|
|
92 |
|
@param |
93 |
|
|
94 |
|
@return@link |
95 |
|
|
96 |
|
|
|
|
| 90% |
Uncovered Elements: 2 (20) |
Complexity: 5 |
Complexity Density: 0,42 |
|
97 |
33 |
@SuppressWarnings("null")... |
98 |
|
@Nonnull |
99 |
|
public static List<Xpp3Dom> getChildrenNodes(@Nullable final Xpp3Dom parentNode, final String name) { |
100 |
33 |
if (parentNode == null) { |
101 |
2 |
return Collections.emptyList(); |
102 |
|
} |
103 |
31 |
final Xpp3Dom[] children = parentNode.getChildren(); |
104 |
31 |
if (children == null) { |
105 |
0 |
return Collections.emptyList(); |
106 |
|
} |
107 |
31 |
final List<Xpp3Dom> list = Lists.newArrayListWithCapacity(children.length); |
108 |
31 |
for (final Xpp3Dom child : children) { |
109 |
51 |
if (name != null) { |
110 |
41 |
if (name.equals(child.getName())) { |
111 |
31 |
list.add(child); |
112 |
|
} |
113 |
|
} else { |
114 |
10 |
list.add(child); |
115 |
|
} |
116 |
|
} |
117 |
|
|
118 |
31 |
return list; |
119 |
|
} |
120 |
|
} |