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