001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019package org.eclipse.aether.internal.test.util; 020 021import org.eclipse.aether.version.Version; 022 023/** 024 * Version ordering by {@link String#compareToIgnoreCase(String)}. 025 */ 026public final class TestVersion implements Version { 027 028 private final String version; 029 030 public TestVersion(String version) { 031 this.version = version == null ? "" : version; 032 } 033 034 public int compareTo(Version o) { 035 return version.compareTo(o.toString()); 036 } 037 038 @Override 039 public int hashCode() { 040 final int prime = 31; 041 int result = prime + version.hashCode(); 042 return result; 043 } 044 045 @Override 046 public boolean equals(Object obj) { 047 if (this == obj) { 048 return true; 049 } 050 if (obj == null) { 051 return false; 052 } 053 if (getClass() != obj.getClass()) { 054 return false; 055 } 056 TestVersion other = (TestVersion) obj; 057 if (!version.equals(other.version)) { 058 return false; 059 } 060 return true; 061 } 062 063 @Override 064 public String toString() { 065 return version; 066 } 067}