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

File TocSidebar.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart9.png
22% of files have more coverage

Code metrics

10
26
9
1
154
64
14
0,54
2,89
9
1,56

Classes

Class Line # Actions
TocSidebar 25 26 0% 14 7
0.8444444584,4%
 

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 TocSidebar extends Toc<TocSidebar> {
26   
27    /** fixed position by default */
28    private boolean fixed = true;
29   
30    /** expanded by default. */
31    private boolean expanded = true;
32   
33    /** auto expandable by default. */
34    private boolean autoExpandable = true;
35   
36    /** heading level limit to display. all by default */
37    private int level = 0;
38   
39    /**
40    * Default constructor.
41    *
42    * @param config
43    * a config (can <b>not</b> be {@code null}).
44    */
 
45  1 toggle public TocSidebar(final @Nonnull ISkinConfig config) {
46  1 super(config, "sidebar", "sidebar");
47  1 final String position = config.getAttributeValue("toc", "position", String.class, "fixed").toLowerCase();
48  1 this.withEnabled(true)
49    .withExpanded(config.getAttributeValue("toc", "expanded", Boolean.class, true))
50    .withAutoExpandable(config.getAttributeValue("toc", "autoExpandable", Boolean.class, true))
51    .withFixed("fixed".equals(position))
52    .withLevel(config.getAttributeValue("toc", "level", Integer.class, 0));
53  1 if (this.isEnabled()) {
54  1 this.addCssOptions("toc-sidebar-enabled");
55    }
56  1 if (isExpanded()) {
57  1 this.addCssOptions("toc-sidebar-expanded");
58    }
59  1 if (isAutoExpandable()) {
60  1 this.addCssOptions("toc-sidebar-autoexpandable");
61    }
62  1 if (isFixed()) {
63  1 this.addCssOptions("toc-sidebar-fixed");
64    } else {
65  0 this.addCssOptions("toc-sidebar-relative");
66    }
67    }
68   
69    /**
70    * Gets the indicating whether is fixed.
71    *
72    * @return Returns {@code true} if is fixed, otherwise {@code false}.
73    */
 
74  1 toggle public boolean isFixed() {
75  1 return fixed;
76    }
77   
78    /**
79    * Sets the indicating whether is fixed.
80    *
81    * @param fixed
82    * {@code true} is fixed.
83    * @return Returns the fluent instance.
84    */
 
85  1 toggle protected TocSidebar withFixed(final boolean fixed) {
86  1 this.fixed = fixed;
87  1 return self();
88    }
89   
90    /**
91    * Gets the indicating whether is expanded.
92    *
93    * @return Returns {@code true} if is expanded, otherwise {@code false}.
94    */
 
95  1 toggle public boolean isExpanded() {
96  1 return expanded;
97    }
98   
99    /**
100    * Sets the indicating whether is expanded.
101    *
102    * @param expanded
103    * {@code true} is expanded.
104    * @return Returns the fluent instance.
105    */
 
106  1 toggle protected TocSidebar withExpanded(final boolean expanded) {
107  1 this.expanded = expanded;
108  1 return self();
109    }
110   
111    /**
112    * Gets the indicating whether is auto-expanded.
113    *
114    * @return Returns {@code true} if is expanded, otherwise {@code false}.
115    */
 
116  1 toggle public boolean isAutoExpandable() {
117  1 return autoExpandable;
118    }
119   
120    /**
121    * Sets the indicating whether is auto-expanded.
122    *
123    * @param autoExpandable
124    * {@code true} is auto-expanded.
125    * @return Returns the fluent instance.
126    */
 
127  1 toggle protected TocSidebar withAutoExpandable(final boolean autoExpandable) {
128  1 this.autoExpandable = autoExpandable;
129  1 return self();
130    }
131   
132    /**
133    * @return Returns the level limit to display.
134    */
 
135  1 toggle public int getLevel() {
136  1 return level;
137    }
138   
139    /**
140    * Sets the level limit to display
141    *
142    * @param level
143    * the level to use.
144    * @return Returns the fluent instance.
145    */
 
146  1 toggle protected TocSidebar withLevel(final int level) {
147  1 if (level < 1) {
148  1 this.level = Integer.MAX_VALUE;
149    } else {
150  0 this.level = level;
151    }
152  1 return self();
153    }
154    }