1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.plugins.javadoc;
20
21
22
23
24
25
26
27
28
29
30
31
32 @Deprecated
33 public class JavadocVersion implements Comparable<JavadocVersion> {
34 private String rawVersion;
35
36 private JavadocVersion(String rawVersion) {
37 if (rawVersion == null || rawVersion.isEmpty()) {
38 throw new IllegalArgumentException("The rawVersion could not be null.");
39 }
40 this.rawVersion = rawVersion;
41 }
42
43
44
45
46
47
48
49 static JavadocVersion parse(String s) {
50 return new JavadocVersion(s);
51 }
52
53 @Override
54 public int compareTo(JavadocVersion other) {
55 String[] thisSegments = this.rawVersion.split("\\.");
56 String[] otherSegments = other.rawVersion.split("\\.");
57
58 int minSegments = Math.min(thisSegments.length, otherSegments.length);
59
60 for (int index = 0; index < minSegments; index++) {
61 int thisValue = Integer.parseInt(thisSegments[index]);
62 int otherValue = Integer.parseInt(otherSegments[index]);
63
64 int compareValue = Integer.compare(thisValue, otherValue);
65
66 if (compareValue != 0) {
67 return compareValue;
68 }
69 }
70
71 return thisSegments.length - otherSegments.length;
72 }
73
74 @Override
75 public String toString() {
76 return rawVersion;
77 }
78 }