1. Project Clover database mar. janv. 20 2026 12:32:22 CET
  2. Package org.devacfr.maven.skins.reflow.model

File MenuItem.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart4.png
88% of files have more coverage

Code metrics

6
27
9
1
144
67
12
0,44
3
9
1,33

Classes

Class Line # Actions
29 27 0% 12 28
0.3333333433,3%
 

Contributing tests

This file is covered by 11 tests. .

Source view

1    /*
2    * Copyright 2012-2025 Christophe Friederich
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10    * Unless required by applicable law or agreed to in writing, software
11    * distributed under the License is distributed on an "AS IS" BASIS,
12    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13    * See the License for the specific language governing permissions and
14    * limitations under the License.
15    */
16    package org.devacfr.maven.skins.reflow.model;
17   
18    import com.google.common.collect.Lists;
19    import java.util.List;
20    import java.util.Objects;
21    import javax.annotation.Nonnull;
22    import org.apache.maven.doxia.site.Image;
23    import org.devacfr.maven.skins.reflow.ISkinConfig;
24   
25    /**
26    * @author Christophe Friederich
27    * @since 2.0
28    */
 
29    public class MenuItem {
30   
31    /** */
32    private final String name;
33   
34    /** */
35    private final String href;
36   
37    /** */
38    private final Image image;
39   
40    /** */
41    private final String target;
42   
43    /** **/
44    private final String inherit;
45   
46    /** */
47    private final boolean active;
48   
49    /** */
50    private final List<MenuItem> menuItems = Lists.newArrayList();
51   
52    /**
53    * Initialize with {@link org.apache.maven.doxia.site.MenuItem}.
54    *
55    * @param config
56    * a config (can <b>not</b> be {@code null}).
57    * @param item
58    * item menu used to.
59    */
 
60  165 toggle public MenuItem(@Nonnull final ISkinConfig config, final org.apache.maven.doxia.site.MenuItem item) {
61  165 Objects.requireNonNull(item);;
62  165 this.href = config.relativeLink(item.getHref());
63  165 this.image = item.getImage();
64  165 this.name = item.getName();
65  165 this.target = item.getTarget();
66  165 this.active = config.isActiveLink(this.href);
67  165 this.inherit = null;
68  165 recurciveAddItem(config, this.menuItems, item.getItems());
69    }
70   
71    /**
72    * recurcive
73    */
 
74  165 toggle private void recurciveAddItem(final ISkinConfig config,
75    final List<MenuItem> menuItems,
76    final List<org.apache.maven.doxia.site.MenuItem> origMenuItems) {
77  165 if (origMenuItems == null) {
78  0 return;
79    }
80  165 for (final org.apache.maven.doxia.site.MenuItem menuItem : origMenuItems) {
81  0 menuItems.add(new MenuItem(config, menuItem));
82    }
83    }
84   
85    /**
86    * @return the name
87    */
 
88  0 toggle public String getName() {
89  0 return name;
90    }
91   
92    /**
93    * @return the menuItems
94    */
 
95  0 toggle public List<MenuItem> getMenuItems() {
96  0 return menuItems;
97    }
98   
99    /**
100    * @return the inherit
101    */
 
102  0 toggle public String getInherit() {
103  0 return inherit;
104    }
105   
106    /**
107    * @return the active
108    */
 
109  0 toggle public boolean isActive() {
110  0 boolean active = this.active;
111  0 if (active) {
112  0 return active;
113    }
114  0 for (final MenuItem menuItem : menuItems) {
115  0 active = menuItem.isActive();
116  0 if (active) {
117  0 break;
118    }
119    }
120  0 return active;
121    }
122   
123    /**
124    * @return the href
125    */
 
126  0 toggle public String getHref() {
127  0 return href;
128    }
129   
130    /**
131    * @return the image
132    */
 
133  0 toggle public Image getImage() {
134  0 return image;
135    }
136   
137    /**
138    * @return the target
139    */
 
140  0 toggle public String getTarget() {
141  0 return target;
142    }
143   
144    }