1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.model.reference

File EntityReferenceTree.java

 

Coverage histogram

../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

0
8
4
1
82
27
4
0.5
2
4
1

Classes

Class Line # Actions
EntityReferenceTree 39 8 0% 4 0
1.0100%
 

Contributing tests

This file is covered by 14 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.model.reference;
21   
22    import java.util.Comparator;
23   
24    /**
25    * Expose a set of references as a tree. The sort order is configurable using a {@link Comparator}. By default the
26    * references will be sorted in default {@link String} order.
27    * <p>
28    * Only a set of references starting at same level is supported. For example you can pass the following lists:
29    * <ul>
30    * <li>[<code>wiki:space.page</code>, <code>wiki2:space2.page2</code>]</li>
31    * <li>[<code>wiki:space.page</code>, <code>wiki:space</code>]</li>
32    * <li>[<code>space.page</code>, <code>space</code>]</li>
33    * </ul>
34    * but not [<code>space.page</code>, <code>wiki:space</code>].
35    *
36    * @version $Id: 231c2f65806270e48ce0a1aae8ecbee2d73d3921 $
37    * @since 5.4RC1
38    */
 
39    public class EntityReferenceTree extends EntityReferenceTreeNode
40    {
41    /**
42    * @param references the references to fill the tree with
43    */
 
44  26 toggle public EntityReferenceTree(Iterable< ? extends EntityReference> references)
45    {
46  26 this(null, references);
47    }
48   
49    /**
50    * @param references the references to fill the tree with
51    */
 
52  4 toggle public EntityReferenceTree(EntityReference... references)
53    {
54  4 this(null, references);
55    }
56   
57    /**
58    * @param comparator control the order of references names
59    * @param references the references to fill the tree with
60    */
 
61  26 toggle public EntityReferenceTree(Comparator<String> comparator, Iterable< ? extends EntityReference> references)
62    {
63  26 super(comparator);
64   
65  26 for (EntityReference reference : references) {
66  36 addChild(reference);
67    }
68    }
69   
70    /**
71    * @param comparator control the order of references names
72    * @param references the references to fill the tree with
73    */
 
74  4 toggle public EntityReferenceTree(Comparator<String> comparator, EntityReference... references)
75    {
76  4 super(comparator);
77   
78  4 for (EntityReference reference : references) {
79  8 addChild(reference);
80    }
81    }
82    }