1. Project Clover database mar. avr. 16 2024 08:19:06 CEST
  2. Package org.devacfr.maven.skins.reflow.model

File MenuItem.java

 

Coverage histogram

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

Code metrics

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

Classes

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

Contributing tests

No tests hitting this source file were found.

Source view

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