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

File TocSidebar.java

 

Coverage histogram

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

Code metrics

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

Classes

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

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