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

File WikiReference.java

 

Coverage histogram

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

Code metrics

4
8
4
1
98
33
6
0.75
2
4
1.5

Classes

Class Line # Actions
WikiReference 35 8 0% 6 2
0.87587.5%
 

Contributing tests

This file is covered by 1016 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.lang.reflect.Type;
23   
24    import javax.inject.Provider;
25   
26    import org.xwiki.component.util.DefaultParameterizedType;
27    import org.xwiki.model.EntityType;
28   
29    /**
30    * Represents a reference to a wiki (wiki name). This is the topmost reference and it doesn't have a parent reference.
31    *
32    * @version $Id: 0bedc1f735306105b5f171fc1b1f826d1f10b05c $
33    * @since 2.2M1
34    */
 
35    public class WikiReference extends EntityReference
36    {
37    /**
38    * The {@link Type} for a {@code Provider<WikiReference>}.
39    *
40    * @since 7.2M1
41    */
42    public static final Type TYPE_PROVIDER = new DefaultParameterizedType(null, Provider.class, WikiReference.class);
43   
44    /**
45    * Special constructor that transforms a generic entity reference into a {@link WikiReference}. It checks the
46    * validity of the passed reference (ie correct type).
47    *
48    * @param reference the raw reference to build this wiki reference from
49    * @throws IllegalArgumentException if the passed reference is not a valid wiki reference
50    */
 
51  178643 toggle public WikiReference(EntityReference reference)
52    {
53  178638 super(reference);
54    }
55   
56    /**
57    * @param wikiName the name of the wiki referenced
58    */
 
59  4851548 toggle public WikiReference(String wikiName)
60    {
61  4851553 super(wikiName, EntityType.WIKI);
62    }
63   
64    /**
65    * {@inheritDoc}
66    * <p>
67    * Overridden in order to verify the validity of the passed type.
68    * </p>
69    *
70    * @throws IllegalArgumentException if the passed type is not a wiki type
71    */
 
72  5030226 toggle @Override
73    protected void setType(EntityType type)
74    {
75  5030194 if (type != EntityType.WIKI) {
76  1 throw new IllegalArgumentException("Invalid type [" + type + "] for a wiki reference");
77    }
78   
79  5030241 super.setType(EntityType.WIKI);
80    }
81   
82    /**
83    * {@inheritDoc}
84    * <p>
85    * Overridden in order to verify the validity of the passed parent.
86    * </p>
87    *
88    * @throws IllegalArgumentException if the passed type is not a wiki type
89    */
 
90  5030191 toggle @Override
91    protected void setParent(EntityReference parent)
92    {
93  5030193 super.setParent(parent);
94  5030129 if (parent != null) {
95  0 throw new IllegalArgumentException("Unexpected parent [" + parent + "] in a wiki reference");
96    }
97    }
98    }