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

File ComponentDeclaration.java

 

Coverage histogram

../../../../img/srcFileCovDistChart8.png
54% of files have more coverage

Code metrics

6
15
7
1
118
52
10
0.67
2.14
7
1.43

Classes

Class Line # Actions
ComponentDeclaration 31 15 0% 10 8
0.7142857371.4%
 

Contributing tests

This file is covered by 28 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.annotation;
21   
22    import org.apache.commons.lang3.builder.EqualsBuilder;
23    import org.apache.commons.lang3.builder.HashCodeBuilder;
24   
25    /**
26    * Represents a Component declaration (i.e. component implementation class name and component priority).
27    *
28    * @version $Id: d038233916a5a575e3c0499a402431ce9e267d7e $
29    * @since 3.3M1
30    */
 
31    public class ComponentDeclaration
32    {
33    /**
34    * Default priorities under which components are registered when no explicit priority is defined.
35    */
36    private static final int DEFAULT_PRIORITY = 1000;
37   
38    /**
39    * @see #getPriority()
40    */
41    private int priority;
42   
43    /**
44    * @see #getImplementationClassName()
45    */
46    private String implementationClassName;
47   
48    /**
49    * @param implementationClassName see {@link #getImplementationClassName()}
50    * @since 4.2M1
51    */
 
52  678653 toggle public ComponentDeclaration(String implementationClassName)
53    {
54  678653 this(implementationClassName, DEFAULT_PRIORITY);
55    }
56   
57    /**
58    * @param implementationClassName see {@link #getImplementationClassName()}
59    * @param priority see {@link #getPriority()}
60    */
 
61  683186 toggle public ComponentDeclaration(String implementationClassName, int priority)
62    {
63  683186 this.implementationClassName = implementationClassName;
64  683186 this.priority = priority;
65    }
66   
67    /**
68    * @return the priority this component declaration has (when several components are registered for the same Role and
69    * Hint the priority is used to decide which one gets registered - the lowest value wins)
70    */
 
71  1440195 toggle public int getPriority()
72    {
73  1440195 return this.priority;
74    }
75   
76    /**
77    * @return the component implementation class name for the declared component
78    */
 
79  1379444 toggle public String getImplementationClassName()
80    {
81  1379444 return this.implementationClassName;
82    }
83   
84    // Object
85   
 
86  90 toggle @Override
87    public boolean equals(Object object)
88    {
89  90 if (object == null) {
90  0 return false;
91    }
92   
93  90 if (object == this) {
94  0 return true;
95    }
96   
97  90 if (object.getClass() != getClass()) {
98  0 return false;
99    }
100   
101  90 ComponentDeclaration rhs = (ComponentDeclaration) object;
102   
103  90 return new EqualsBuilder().append(getImplementationClassName(), rhs.getImplementationClassName())
104    .append(getPriority(), rhs.getPriority()).isEquals();
105    }
106   
 
107  26163 toggle @Override
108    public int hashCode()
109    {
110  26163 return new HashCodeBuilder(5, 45).append(getImplementationClassName()).append(getPriority()).toHashCode();
111    }
112   
 
113  0 toggle @Override
114    public String toString()
115    {
116  0 return String.valueOf(this.priority) + ':' + this.implementationClassName;
117    }
118    }