View Javadoc
1   package org.apache.maven.shared.release.versions;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.maven.artifact.versioning.ArtifactVersion;
23  import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
24  
25  class MavenArtifactVersion
26      implements ArtifactVersion
27  {
28      private final ArtifactVersion version;
29  
30      public MavenArtifactVersion( String version )
31      {
32          this.version = new DefaultArtifactVersion( version );
33      }
34  
35      public int compareTo( Object o )
36      {
37          if ( o instanceof MavenArtifactVersion )
38          {
39              return version.compareTo( ( (MavenArtifactVersion) o ).version );
40          }
41          else
42          {
43              return version.compareTo( version );
44          }
45      }
46  
47      public int getMajorVersion()
48      {
49          return version.getMajorVersion();
50      }
51  
52      public int getMinorVersion()
53      {
54          return version.getMinorVersion();
55      }
56  
57      public int getIncrementalVersion()
58      {
59          return version.getIncrementalVersion();
60      }
61  
62      public int getBuildNumber()
63      {
64          return version.getBuildNumber();
65      }
66  
67      public String getQualifier()
68      {
69          return version.getQualifier();
70      }
71  
72      public void parseVersion( String version )
73      {
74          this.version.parseVersion( version );
75      }
76  
77      @Override
78      public String toString()
79      {
80          return this.version.toString();
81      }
82  
83      @Override
84      public int hashCode()
85      {
86          return this.version.hashCode();
87      }
88      
89      @Override
90      public boolean equals( Object other )
91      {
92          if ( this == other )
93          {
94              return true;
95          }
96          if ( other == null )
97          {
98              return false;
99          }
100 
101         if ( other instanceof MavenArtifactVersion )
102         {
103             return version.equals( ( (MavenArtifactVersion) other ).version );
104         }
105         return false;
106     }
107 
108     
109 }