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.model; |
20 |
|
|
21 |
|
import static com.google.common.base.Strings.isNullOrEmpty; |
22 |
|
import static java.util.Objects.requireNonNull; |
23 |
|
|
24 |
|
import java.util.List; |
25 |
|
import java.util.Objects; |
26 |
|
|
27 |
|
import javax.annotation.Nonnull; |
28 |
|
|
29 |
|
import org.apache.maven.doxia.site.Image; |
30 |
|
import org.apache.maven.doxia.site.LinkItem; |
31 |
|
import org.devacfr.maven.skins.reflow.ISkinConfig; |
32 |
|
|
33 |
|
import com.google.common.collect.Lists; |
34 |
|
|
35 |
|
|
36 |
|
@author |
37 |
|
@since |
38 |
|
|
|
|
| 48,1% |
Uncovered Elements: 27 (52) |
Complexity: 13 |
Complexity Density: 0,36 |
|
39 |
|
public class Menu { |
40 |
|
|
41 |
|
|
42 |
|
private final String name; |
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
private final String href; |
48 |
|
|
49 |
|
|
50 |
|
private final Image image; |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
private final String target; |
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
private final String inherit; |
60 |
|
|
61 |
|
|
62 |
|
private final boolean active; |
63 |
|
|
64 |
|
|
65 |
|
private final List<MenuItem> menuItems = Lists.newArrayList(); |
66 |
|
|
67 |
|
|
68 |
|
@link |
69 |
|
|
70 |
|
@param |
71 |
|
|
72 |
|
@param |
73 |
|
|
74 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0,14 |
|
75 |
6 |
public Menu(@Nonnull final ISkinConfig config, @Nonnull final LinkItem item) {... |
76 |
6 |
Objects.requireNonNull(item); |
77 |
6 |
this.href = config.relativeLink(item.getHref()); |
78 |
6 |
this.image = item.getImage(); |
79 |
6 |
this.name = item.getName(); |
80 |
6 |
this.target = item.getTarget(); |
81 |
6 |
this.active = config.isActiveLink(this.href); |
82 |
6 |
this.inherit = null; |
83 |
|
} |
84 |
|
|
85 |
|
|
86 |
|
@link |
87 |
|
|
88 |
|
@param |
89 |
|
|
90 |
|
@param |
91 |
|
|
92 |
|
|
|
|
| 85,7% |
Uncovered Elements: 2 (14) |
Complexity: 2 |
Complexity Density: 0,17 |
|
93 |
42 |
public Menu(@Nonnull final ISkinConfig config, @Nonnull final org.apache.maven.doxia.site.Menu menu) {... |
94 |
42 |
Objects.requireNonNull(menu); |
95 |
42 |
this.href = null; |
96 |
42 |
this.image = menu.getImage(); |
97 |
42 |
this.name = menu.getName(); |
98 |
42 |
this.target = null; |
99 |
42 |
this.inherit = menu.getInherit(); |
100 |
42 |
this.active = false; |
101 |
42 |
final List<org.apache.maven.doxia.site.MenuItem> items = menu.getItems(); |
102 |
42 |
for (final org.apache.maven.doxia.site.MenuItem menuItem : items) { |
103 |
90 |
if (isNullOrEmpty(menu.getName())) { |
104 |
0 |
continue; |
105 |
|
} |
106 |
90 |
this.menuItems.add(new MenuItem(config, menuItem)); |
107 |
|
} |
108 |
|
} |
109 |
|
|
110 |
|
|
111 |
|
@return |
112 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
113 |
0 |
public List<MenuItem> getMenuItems() {... |
114 |
0 |
return menuItems; |
115 |
|
} |
116 |
|
|
117 |
|
|
118 |
|
@return |
119 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
120 |
0 |
public String getName() {... |
121 |
0 |
return name; |
122 |
|
} |
123 |
|
|
124 |
|
|
125 |
|
@return |
126 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
127 |
0 |
public String getInherit() {... |
128 |
0 |
return inherit; |
129 |
|
} |
130 |
|
|
131 |
|
|
132 |
|
@return |
133 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 3 |
Complexity Density: 0,38 |
|
134 |
0 |
public boolean isActive() {... |
135 |
0 |
boolean active = this.active; |
136 |
0 |
if (active) { |
137 |
0 |
return active; |
138 |
|
} |
139 |
0 |
for (final MenuItem menuItem : menuItems) { |
140 |
0 |
active = menuItem.isActive(); |
141 |
0 |
if (active) { |
142 |
0 |
break; |
143 |
|
} |
144 |
|
} |
145 |
0 |
return active; |
146 |
|
} |
147 |
|
|
148 |
|
|
149 |
|
|
150 |
|
|
151 |
|
|
152 |
|
@return |
153 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
154 |
0 |
public String getHref() {... |
155 |
0 |
return href; |
156 |
|
} |
157 |
|
|
158 |
|
|
159 |
|
@return |
160 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
161 |
0 |
public Image getImage() {... |
162 |
0 |
return image; |
163 |
|
} |
164 |
|
|
165 |
|
|
166 |
|
|
167 |
|
@return |
168 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
169 |
0 |
public String getTarget() {... |
170 |
0 |
return target; |
171 |
|
} |
172 |
|
|
173 |
|
|
174 |
|
|
175 |
|
|
176 |
|
|
177 |
|
|
178 |
|
|
179 |
|
@param |
180 |
|
|
181 |
|
@param |
182 |
|
|
183 |
|
@return |
184 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
|
185 |
120 |
public static boolean matches(@Nonnull final String regex, @Nonnull final org.apache.maven.doxia.site.Menu menu) {... |
186 |
120 |
requireNonNull(regex); |
187 |
120 |
requireNonNull(menu); |
188 |
120 |
return menu.getRef() != null && menu.getRef().matches(regex) |
189 |
|
|| menu.getName() != null && menu.getName().matches(regex); |
190 |
|
} |
191 |
|
} |