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

File Footer.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart8.png
36% of files have more coverage

Code metrics

8
28
4
2
127
60
10
0,36
7
2
2,5

Classes

Class Line # Actions
40 24 0% 8 9
0.735294173,5%
Footer.Column 103 4 0% 2 2
0.666666766,7%
 

Contributing tests

This file is covered by 11 tests. .

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 static java.util.Objects.requireNonNull;
22   
23    import java.util.List;
24   
25    import javax.annotation.Nonnull;
26   
27    import org.apache.maven.doxia.site.SiteModel;
28    import org.codehaus.plexus.util.xml.Xpp3Dom;
29    import org.devacfr.maven.skins.reflow.ISkinConfig;
30   
31    import com.google.common.base.Strings;
32    import com.google.common.collect.Lists;
33   
34    /**
35    * Represents the footer component.
36    *
37    * @author devacfr
38    * @since 2.0
39    */
 
40    public class Footer extends BsComponent {
41   
42    /** */
43    private static final String COMPONENT = "footer";
44   
45    /** */
46    private final List<Column> columns = Lists.newArrayList();
47   
48    /**
49    * Default constructor.
50    *
51    * @param config
52    * a config (can not be {@code null}).
53    */
 
54  17 toggle public Footer(@Nonnull final ISkinConfig config) {
55  17 super(COMPONENT);
56  17 requireNonNull(config);
57  17 this.setTheme(config.getAttributeValue(COMPONENT, "theme", String.class, "light"));
58  17 this.setBackground(config.getAttributeValue(COMPONENT, "background", String.class, "light"));
59  17 this.setCssClass(config.getAttributeValue(COMPONENT, "cssClass", String.class, null));
60   
61  17 final Xpp3Dom bottomNav = config.get("bottomNav");
62  17 final SiteModel model = config.getSiteModel();
63   
64  17 if (model.getBody() != null && model.getBody().getMenus() != null) {
65  6 final List<org.apache.maven.doxia.site.Menu> menus = model.getBody().getMenus();
66  6 if (bottomNav != null && bottomNav.getChildren().length > 0) {
67    // foreach columns
68  6 for (final Xpp3Dom col : bottomNav.getChildren()) {
69  18 final String regex = col.getValue();
70  18 if (Strings.isNullOrEmpty(regex)) {
71  0 continue;
72    }
73  18 final List<Menu> amenus = Lists.newArrayList();
74  18 for (final org.apache.maven.doxia.site.Menu menu : menus) {
75    // add in column, if matches with regex
76  90 if (Menu.matches(regex, menu)) {
77  30 amenus.add(new Menu(config, menu));
78    }
79    }
80  18 this.columns.add(new Column(config, amenus));
81    }
82    } else {
83  0 final List<Menu> amenus = Lists.newArrayList();
84  0 for (final org.apache.maven.doxia.site.Menu menu : menus) {
85  0 amenus.add(new Menu(config, menu));
86    }
87  0 this.columns.add(new Column(config, amenus));
88    }
89    }
90    }
91   
92    /**
93    * @return Returns a list of {@link Column}.
94    */
 
95  0 toggle public List<Column> getColumns() {
96  0 return columns;
97    }
98   
99    /**
100    * @author Christophe Friederich
101    * @since 2.0
102    */
 
103    public static class Column {
104   
105    /** */
106    private final List<Menu> menus;
107   
108    /**
109    * @param config
110    * a config (can not be {@code null}).
111    * @param menus
112    * list of menu.
113    */
 
114  18 toggle public Column(@Nonnull final ISkinConfig config, @Nonnull final List<Menu> menus) {
115  18 requireNonNull(config);
116  18 requireNonNull(menus);
117  18 this.menus = menus;
118    }
119   
120    /**
121    * @return Returns a list of {@link Menu}.
122    */
 
123  0 toggle public List<Menu> getMenus() {
124  0 return menus;
125    }
126    }
127    }