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

File Namespace.java

 

Coverage histogram

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

Code metrics

6
19
6
1
105
52
9
0.47
3.17
6
1.5

Classes

Class Line # Actions
Namespace 31 19 0% 9 10
0.6774193667.7%
 

Contributing tests

This file is covered by 40 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.component.namespace;
21   
22    import org.apache.commons.lang3.StringUtils;
23    import org.apache.commons.lang3.builder.HashCodeBuilder;
24   
25    /**
26    * A namespace.
27    *
28    * @version $Id: 31292fe6ec6dc8ebf4dad168c8bcc3ca6731630f $
29    * @since 9.0RC1
30    */
 
31    public class Namespace
32    {
33    private String type;
34   
35    private String value;
36   
37    /**
38    * @param type the optional type
39    * @param value the value
40    */
 
41  335 toggle public Namespace(String type, String value)
42    {
43  335 this.type = type;
44  335 this.value = value;
45    }
46   
47    /**
48    * @return the namespace type (can be null)
49    */
 
50  612 toggle public String getType()
51    {
52  612 return this.type;
53    }
54   
55    /**
56    * @return the namespace value
57    */
 
58  216 toggle public String getValue()
59    {
60  216 return this.value;
61    }
62   
 
63  4 toggle @Override
64    public boolean equals(Object other)
65    {
66  4 if (this == other) {
67  0 return true;
68    }
69   
70  4 if (other instanceof Namespace) {
71  4 return StringUtils.equals(this.type, ((Namespace) other).getType())
72    && StringUtils.equals(this.value, ((Namespace) other).getValue());
73    }
74   
75  0 return false;
76    }
77   
 
78  0 toggle @Override
79    public int hashCode()
80    {
81  0 HashCodeBuilder builder = new HashCodeBuilder();
82   
83  0 builder.append(this.type);
84  0 builder.append(this.value);
85   
86  0 return builder.toHashCode();
87    }
88   
 
89  1 toggle @Override
90    public String toString()
91    {
92  1 StringBuilder builder = new StringBuilder();
93   
94    // Type
95  1 if (this.type != null) {
96  1 builder.append(this.type.replace("\\", "\\\\").replace(":", "\\:"));
97  1 builder.append(':');
98    }
99   
100    // Value
101  1 builder.append(this.value);
102   
103  1 return builder.toString();
104    }
105    }