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

File TocTopBar.java

 

Coverage histogram

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

Code metrics

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

Classes

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

Contributing tests

This file is covered by 1 test. .

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