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

File DefaultExtensionRating.java

 

Coverage histogram

../../../../img/srcFileCovDistChart6.png
69% of files have more coverage

Code metrics

4
17
6
1
107
53
8
0.47
2.83
6
1.33

Classes

Class Line # Actions
DefaultExtensionRating 31 17 0% 8 13
0.518518551.9%
 

Contributing tests

No tests hitting this source file were found.

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.extension.rating;
21   
22    import org.apache.commons.lang3.builder.HashCodeBuilder;
23    import org.xwiki.extension.repository.rating.RatableExtensionRepository;
24   
25    /**
26    * Default implementation of ExtensionRating.
27    *
28    * @version $Id: 76dda9fd713c710a2aea5714e09b2ae6082e023a $
29    * @since 6.2M2
30    */
 
31    public class DefaultExtensionRating implements ExtensionRating
32    {
33    /**
34    * @see #getTotalVotes()
35    */
36    private int totalVotes;
37   
38    /**
39    * @see #getAverageVote()
40    */
41    private float averageVote;
42   
43    /**
44    * @see #getRepository()
45    */
46    private RatableExtensionRepository repository;
47   
48    /**
49    * @param totalVotes the total number of votes
50    * @param averageVote the average of all votes
51    * @param repository the repository from which the rating comes from
52    */
 
53  67 toggle public DefaultExtensionRating(int totalVotes, float averageVote, RatableExtensionRepository repository)
54    {
55  67 this.totalVotes = totalVotes;
56  67 this.averageVote = averageVote;
57  67 this.repository = repository;
58    }
59   
 
60  60 toggle @Override
61    public int getTotalVotes()
62    {
63  60 return this.totalVotes;
64    }
65   
 
66  30 toggle @Override
67    public float getAverageVote()
68    {
69  30 return this.averageVote;
70    }
71   
 
72  0 toggle @Override
73    public RatableExtensionRepository getRepository()
74    {
75  0 return this.repository;
76    }
77   
78    // Object
79   
 
80  0 toggle @Override
81    public boolean equals(Object obj)
82    {
83  0 if (obj == this) {
84  0 return true;
85    }
86   
87  0 if (obj instanceof ExtensionRating) {
88  0 ExtensionRating rating = (ExtensionRating) obj;
89  0 return this.totalVotes == rating.getTotalVotes() && this.averageVote == rating.getAverageVote()
90    && this.repository == rating.getRepository();
91    } else {
92  0 return false;
93    }
94    }
95   
 
96  30 toggle @Override
97    public int hashCode()
98    {
99  30 HashCodeBuilder builder = new HashCodeBuilder();
100   
101  30 builder.append(this.totalVotes);
102  30 builder.append(this.averageVote);
103  30 builder.append(this.repository);
104   
105  30 return builder.toHashCode();
106    }
107    }