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

File TocTopBar.java

 

Coverage histogram

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

Code metrics

2
13
5
1
91
33
6
0,46
2,6
5
1,2

Classes

Class Line # Actions
TocTopBar 25 13 0% 6 5
0.7575%
 

Contributing tests

This file is covered by 1 test. .

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 javax.annotation.Nonnull;
19    import org.devacfr.maven.skins.reflow.ISkinConfig;
20   
21    /**
22    * @author devacfr
23    * @since 2.0
24    */
 
25    public class TocTopBar extends Toc<TocTopBar> {
26   
27    /** no flatten attribute (default) - flatten if single top heading */
28    private boolean flatten = false;
29   
30    /** -1 or no numberItems attribute (default) - unlimited */
31    private int numberItems = -1;
32   
33    /**
34    * Default constructor.
35    *
36    * @param config
37    * a config (can <b>not</b> be {@code null}).
38    */
 
39  1 toggle public TocTopBar(final @Nonnull ISkinConfig config) {
40  1 super(config, "top", "navbar");
41  1 this.setTheme(config.getAttributeValue(COMPONENT, "theme", String.class, "light"));
42  1 this.setBackground(config.getAttributeValue(COMPONENT, "background", String.class, "light"));
43  1 this.setCssClass(config.getAttributeValue(COMPONENT, "cssClass", String.class, null));
44  1 this.withFlatten(config.getAttributeValue(COMPONENT, "flatten", Boolean.class, false))
45    .withNumberItems(config.getAttributeValue(COMPONENT, "numberItems", Integer.class, -1))
46    .withEnabled(true);
47  1 if (isEnabled()) {
48  1 this.addCssOptions("toc-top-enabled");
49    }
50    }
51   
52    /**
53    * Gets the indicating whether is flatten.
54    *
55    * @return Returns {@code true} if is flatten, otherwise {@code false}.
56    */
 
57  0 toggle public boolean isFlatten() {
58  0 return flatten;
59    }
60   
61    /**
62    * Sets the indicating whether is flatten.
63    *
64    * @param flatten
65    * {@code true} to flat.
66    * @return Returns the fluent instance.
67    */
 
68  1 toggle protected TocTopBar withFlatten(final boolean flatten) {
69  1 this.flatten = flatten;
70  1 return self();
71    }
72   
73    /**
74    * @return Returns the number of items to display.
75    */
 
76  0 toggle public int getNumberItems() {
77  0 return numberItems;
78    }
79   
80    /**
81    * Sets the number of items to display.
82    *
83    * @param numberItems
84    * -1 or the number of items to display
85    * @return Returns the fluent instance.
86    */
 
87  1 toggle protected TocTopBar withNumberItems(final int numberItems) {
88  1 this.numberItems = numberItems;
89  1 return self();
90    }
91    }