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

File Header.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart5.png
80% of files have more coverage

Code metrics

6
17
4
1
101
43
7
0,41
4,25
4
1,75

Classes

Class Line # Actions
33 17 0% 7 14
0.481481548,1%
 

Contributing tests

This file is covered by 18 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 static java.util.Objects.requireNonNull;
19   
20    import com.google.common.base.Strings;
21    import com.google.common.collect.Lists;
22    import java.util.List;
23    import javax.annotation.Nonnull;
24    import org.codehaus.plexus.util.xml.Xpp3Dom;
25    import org.devacfr.maven.skins.reflow.ISkinConfig;
26   
27    /**
28    * Represents the header component.
29    *
30    * @author devacfr
31    * @since 2.2
32    */
 
33    public class Header extends BsComponent {
34   
35    /** */
36    private static final String COMPONENT = "header";
37   
38    private static final List<String> HEADER_TYPES = Lists.newArrayList("jumbotron", "banner", "custom");
39   
40    /** */
41    private boolean enabled = true;
42   
43    /** */
44    private String type;
45   
46    /** */
47    private String content;
48   
49    /**
50    * Default constructor.
51    *
52    * @param config
53    * a config (can not be {@code null}).
54    */
 
55  26 toggle public Header(@Nonnull final ISkinConfig config) {
56  26 super(config, COMPONENT);
57  26 requireNonNull(config);
58  26 this.setTheme(config.getAttributeValue(COMPONENT, "theme", String.class, null));
59  26 this.setBackground(config.getAttributeValue(COMPONENT, "background", String.class, null));
60  26 this.setCssClass(config.getAttributeValue(COMPONENT, "cssClass", String.class, null));
61   
62  26 this.type = config.getAttributeValue(COMPONENT, "type", String.class, HEADER_TYPES.get(0)).toLowerCase();
63  26 if (!HEADER_TYPES.contains(this.type)) {
64  0 this.type = HEADER_TYPES.get(0);
65    }
66  26 this.enabled = config.getAttributeValue(COMPONENT, "enabled", Boolean.class, true);
67   
68  26 Xpp3Dom component = config.get(COMPONENT);
69  26 if (component != null) {
70  0 this.content = component.getValue();
71  0 if (!Strings.isNullOrEmpty(this.content)) {
72  0 this.type = HEADER_TYPES.get(2); // enforce the type to custom
73    }
74    }
75    }
76   
77    /**
78    * Gets the indicating whether the header is displayed.
79    *
80    * @return Returns {@code true} whether the header is displayed, otherwise {@code false}.
81    */
 
82  0 toggle public boolean isEnabled() {
83  0 return enabled;
84    }
85   
86    /**
87    * Gets the type of header.
88    *
89    * @return Returns a String representing the type of header.
90    */
 
91  0 toggle public String getType() {
92  0 return type;
93    }
94   
95    /**
96    * @return the content
97    */
 
98  0 toggle public String getContent() {
99  0 return content;
100    }
101    }