Class | Line # | Actions | |||||
---|---|---|---|---|---|---|---|
AverageRatingApi | 29 | 10 | 0% | 7 | 10 |
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.ratings; | |
21 | ||
22 | /** | |
23 | * Api wrapper for an average rating. | |
24 | * | |
25 | * @version $Id: 13d0b04bec06d8e60277ec2e30d439ff222d1c29 $ | |
26 | * @see AverageRating | |
27 | * @since 6.4M3 | |
28 | */ | |
29 | public class AverageRatingApi | |
30 | { | |
31 | /** | |
32 | * The wrapped average rating. | |
33 | */ | |
34 | protected AverageRating averageRating; | |
35 | ||
36 | /** | |
37 | * Constructor of this average rating wrapper. | |
38 | * | |
39 | * @param arating the wrapped rating | |
40 | */ | |
41 | 68 | ![]() |
42 | { | |
43 | 68 | this.averageRating = arating; |
44 | } | |
45 | ||
46 | /** | |
47 | * Gets the number of votes for this average rating. | |
48 | * | |
49 | * @return the number of votes for this average rating | |
50 | * @see AverageRating#getNbVotes() | |
51 | */ | |
52 | 67 | ![]() |
53 | { | |
54 | 67 | if (averageRating == null) { |
55 | 0 | return 0; |
56 | } else { | |
57 | 68 | return averageRating.getNbVotes(); |
58 | } | |
59 | } | |
60 | ||
61 | /** | |
62 | * Gets the average vote. | |
63 | * | |
64 | * @return the average vote | |
65 | * @see AverageRating#getAverageVote() | |
66 | */ | |
67 | 67 | ![]() |
68 | { | |
69 | 68 | if (averageRating == null) { |
70 | 0 | return 0; |
71 | } else { | |
72 | 67 | return averageRating.getAverageVote(); |
73 | } | |
74 | } | |
75 | ||
76 | /** | |
77 | * Gets the method used to compute the average rating. | |
78 | * | |
79 | * @return the method used to compute the average rating | |
80 | * @see AverageRating#getMethod() | |
81 | */ | |
82 | 0 | ![]() |
83 | { | |
84 | 0 | if (averageRating == null) { |
85 | 0 | return ""; |
86 | } else { | |
87 | 0 | return averageRating.getMethod(); |
88 | } | |
89 | } | |
90 | } |