1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
34
35
36
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
56
57
58
59
60 public Header(@Nonnull final ISkinConfig config) {
61 super(COMPONENT);
62 requireNonNull(config);
63 this.setTheme(config.getAttributeValue(COMPONENT, "theme", String.class, null));
64 this.setBackground(config.getAttributeValue(COMPONENT, "background", String.class, null));
65 this.setCssClass(config.getAttributeValue(COMPONENT, "cssClass", String.class, null));
66
67 this.type = config.getAttributeValue(COMPONENT, "type", String.class, HEADER_TYPES.get(0)).toLowerCase();
68 if (!HEADER_TYPES.contains(this.type)) {
69 this.type = HEADER_TYPES.get(0);
70 }
71 this.enabled = config.getAttributeValue(COMPONENT, "enabled", Boolean.class, true);
72
73 Xpp3Dom component = config.get(COMPONENT);
74 if (component != null) {
75 this.content = component.getValue();
76 if (!Strings.isNullOrEmpty(this.content)) {
77 this.type = HEADER_TYPES.get(2);
78 }
79 }
80 }
81
82
83
84
85
86
87 public boolean isEnabled() {
88 return enabled;
89 }
90
91
92
93
94
95
96 public String getType() {
97 return type;
98 }
99
100
101
102
103 public String getContent() {
104 return content;
105 }
106 }