1 package org.eclipse.aether.internal.test.util;
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.eclipse.aether.version.Version;
23
24 /**
25 * Version ordering by {@link String#compareToIgnoreCase(String)}.
26 */
27 final class TestVersion
28 implements Version
29 {
30
31 private String version;
32
33 TestVersion( String version )
34 {
35 this.version = version == null ? "" : version;
36 }
37
38 public int compareTo( Version o )
39 {
40 return version.compareTo( o.toString() );
41 }
42
43 @Override
44 public int hashCode()
45 {
46 final int prime = 31;
47 int result = 1;
48 result = prime * result + ( ( version == null ) ? 0 : version.hashCode() );
49 return result;
50 }
51
52 @Override
53 public boolean equals( Object obj )
54 {
55 if ( this == obj )
56 {
57 return true;
58 }
59 if ( obj == null )
60 {
61 return false;
62 }
63 if ( getClass() != obj.getClass() )
64 {
65 return false;
66 }
67 TestVersion other = (TestVersion) obj;
68 if ( version == null )
69 {
70 if ( other.version != null )
71 {
72 return false;
73 }
74 }
75 else if ( !version.equals( other.version ) )
76 {
77 return false;
78 }
79 return true;
80 }
81
82 @Override
83 public String toString()
84 {
85 return version;
86 }
87
88 }