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

File Components.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart7.png
60% of files have more coverage

Code metrics

8
11
5
1
84
31
9
0,82
2,2
5
1,8

Classes

Class Line # Actions
Components 25 11 0% 9 8
0.666666766,7%
 

Contributing tests

This file is covered by 17 tests. .

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.snippet;
17   
18    import java.util.ArrayList;
19    import org.jsoup.internal.StringUtil;
20   
21    /**
22    * @author Christophe Friederich
23    * @version 2.4
24    */
 
25    public class Components extends ArrayList<Component<?>> {
26   
27    /**
28    * @see java.io.Serializable
29    */
30    private static final long serialVersionUID = 1L;
31   
32    /**
33    * @see Components#empty()
34    */
35    private static final Components EMPTY = new Components();
36   
37    /**
38    * @return an empty Components instance
39    */
 
40  0 toggle public static Components empty() {
41  0 return EMPTY;
42    }
43   
44    /**
45    * Default constructor.
46    */
 
47  655 toggle public Components() {
48    }
49   
50    /**
51    * @return the HTML representation of all components
52    */
 
53  112 toggle public String html() {
54  112 final StringBuilder sb = StringUtil.borrowBuilder();
55  112 for (final Component<?> component : this) {
56  197 if (sb.length() != 0) {
57  85 sb.append("\n");
58    }
59  197 final String html = component.getHtml();
60  197 if (html != null) {
61  197 sb.append(html);
62    }
63    }
64  112 return StringUtil.releaseBuilder(sb);
65    }
66   
67    /**
68    * Get the first matched element.
69    *
70    * @return The first matched component, or <code>null</code> if contents is empty.
71    */
 
72  148 toggle public Component<?> first() {
73  148 return isEmpty() ? null : get(0);
74    }
75   
76    /**
77    * Get the last matched component.
78    *
79    * @return The last matched component, or <code>null</code> if contents is empty.
80    */
 
81  0 toggle public Component<?> last() {
82  0 return isEmpty() ? null : get(size() - 1);
83    }
84    }