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

File Header.java

 

Coverage histogram

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

Code metrics

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

Classes

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

Contributing tests

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