1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
package net.sourceforge.subsonic.androidapp.domain; |
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
@author |
25 |
|
@version |
26 |
|
|
|
|
| 20,4% |
Uncovered Elements: 78 (98) |
Complexity: 27 |
Complexity Density: 0,51 |
|
27 |
|
public class Version implements Comparable<Version> { |
28 |
|
private int major; |
29 |
|
private int minor; |
30 |
|
private int beta; |
31 |
|
private int bugfix; |
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
@param |
36 |
|
|
|
|
| 81,8% |
Uncovered Elements: 2 (11) |
Complexity: 3 |
Complexity Density: 0,43 |
|
37 |
46
|
public Version(String version) {... |
38 |
46
|
String[] s = version.split("\\."); |
39 |
46
|
major = Integer.valueOf(s[0]); |
40 |
46
|
minor = Integer.valueOf(s[1]); |
41 |
|
|
42 |
46
|
if (s.length > 2) { |
43 |
37
|
if (s[2].contains("beta")) { |
44 |
0
|
beta = Integer.valueOf(s[2].replace("beta", "")); |
45 |
|
} else { |
46 |
37
|
bugfix = Integer.valueOf(s[2]); |
47 |
|
} |
48 |
|
} |
49 |
|
} |
50 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
51 |
0
|
public int getMajor() {... |
52 |
0
|
return major; |
53 |
|
} |
54 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
55 |
0
|
public int getMinor() {... |
56 |
0
|
return minor; |
57 |
|
} |
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
@param |
62 |
|
@return |
63 |
|
|
|
|
| 0% |
Uncovered Elements: 22 (22) |
Complexity: 7 |
Complexity Density: 0,58 |
|
64 |
0
|
public boolean equals(Object o) {... |
65 |
0
|
if (this == o) return true; |
66 |
0
|
if (o == null || getClass() != o.getClass()) return false; |
67 |
|
|
68 |
0
|
final Version version = (Version) o; |
69 |
|
|
70 |
0
|
if (beta != version.beta) return false; |
71 |
0
|
if (bugfix != version.bugfix) return false; |
72 |
0
|
if (major != version.major) return false; |
73 |
0
|
return minor == version.minor; |
74 |
|
} |
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
@return |
79 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
|
80 |
0
|
public int hashCode() {... |
81 |
0
|
int result; |
82 |
0
|
result = major; |
83 |
0
|
result = 29 * result + minor; |
84 |
0
|
result = 29 * result + beta; |
85 |
0
|
result = 29 * result + bugfix; |
86 |
0
|
return result; |
87 |
|
} |
88 |
|
|
89 |
|
|
90 |
|
|
91 |
|
@return |
92 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0,43 |
|
93 |
0
|
public String toString() {... |
94 |
0
|
StringBuffer buf = new StringBuffer(); |
95 |
0
|
buf.append(major).append('.').append(minor); |
96 |
0
|
if (beta != 0) { |
97 |
0
|
buf.append(".beta").append(beta); |
98 |
0
|
} else if (bugfix != 0) { |
99 |
0
|
buf.append('.').append(bugfix); |
100 |
|
} |
101 |
|
|
102 |
0
|
return buf.toString(); |
103 |
|
} |
104 |
|
|
105 |
|
|
106 |
|
|
107 |
|
@param |
108 |
|
@return |
109 |
|
|
110 |
|
|
|
|
| 23,1% |
Uncovered Elements: 30 (39) |
Complexity: 11 |
Complexity Density: 0,58 |
|
111 |
9
|
@Override... |
112 |
|
public int compareTo(Version version) { |
113 |
9
|
if (major < version.major) { |
114 |
0
|
return -1; |
115 |
9
|
} else if (major > version.major) { |
116 |
0
|
return 1; |
117 |
|
} |
118 |
|
|
119 |
9
|
if (minor < version.minor) { |
120 |
0
|
return -1; |
121 |
9
|
} else if (minor > version.minor) { |
122 |
9
|
return 1; |
123 |
|
} |
124 |
|
|
125 |
0
|
if (bugfix < version.bugfix) { |
126 |
0
|
return -1; |
127 |
0
|
} else if (bugfix > version.bugfix) { |
128 |
0
|
return 1; |
129 |
|
} |
130 |
|
|
131 |
0
|
int thisBeta = beta == 0 ? Integer.MAX_VALUE : beta; |
132 |
0
|
int otherBeta = version.beta == 0 ? Integer.MAX_VALUE : version.beta; |
133 |
|
|
134 |
0
|
if (thisBeta < otherBeta) { |
135 |
0
|
return -1; |
136 |
0
|
} else if (thisBeta > otherBeta) { |
137 |
0
|
return 1; |
138 |
|
} |
139 |
|
|
140 |
0
|
return 0; |
141 |
|
} |
142 |
|
} |