1 /** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one or more 4 * contributor license agreements. See the NOTICE file distributed with 5 * this work for additional information regarding copyright ownership. 6 * The ASF licenses this file to You under the Apache License, Version 2.0 7 * (the "License"); you may not use this file except in compliance with 8 * the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 package org.apache.geronimo.system.plugin; 19 20 import org.apache.geronimo.kernel.repository.Version; 21 22 /** 23 * SnapshotVersion is like Version but holds extra fields that appear in the 24 * filename of a snapshot artifact. The toString() method is not overriden 25 * because the super implementation produces the correct string for navigating 26 * the directory structure of a plugin repository. The extra fields maintained 27 * in this class are needed for constructing the filename portion of a URL for a 28 * snapshot artifact where the qualifier and build number are replaced with a 29 * snapshot timestamp and build number. 30 * 31 * @version $Revision: 470597 $ $Date: 2006-11-02 15:30:55 -0800 (Thu, 02 Nov 2006) $ 32 * 33 */ 34 public class SnapshotVersion extends Version { 35 private static final long serialVersionUID = -4165276456639945508L; 36 37 private Integer buildNumber; 38 39 private String timestamp; 40 41 public SnapshotVersion(Version version) { 42 super(version.toString()); 43 } 44 45 public SnapshotVersion(String version) { 46 super(version); 47 } 48 49 public int getBuildNumber() { 50 return buildNumber != null ? buildNumber.intValue() : 0; 51 } 52 53 public void setBuildNumber(int buildNumber) { 54 this.buildNumber = new Integer(buildNumber); 55 } 56 57 public String getTimestamp() { 58 return timestamp; 59 } 60 61 public void setTimestamp(String timestamp) { 62 this.timestamp = timestamp; 63 } 64 65 public boolean equals(Object other) { 66 if (super.equals(other)) { 67 if (other instanceof SnapshotVersion) { 68 SnapshotVersion v = (SnapshotVersion) other; 69 if (buildNumber == null ? v.buildNumber != null : !buildNumber.equals(v.buildNumber)) { 70 return false; 71 } 72 if (timestamp == null ? v.timestamp != null : !timestamp.equals(v.timestamp)) { 73 return false; 74 } 75 return true; 76 } 77 } 78 return false; 79 } 80 81 public int hashCode() { 82 int hashCode = super.hashCode(); 83 if (buildNumber != null) { 84 hashCode = 37 * hashCode + buildNumber.hashCode(); 85 } 86 if (timestamp != null) { 87 hashCode = 37 * hashCode + timestamp.hashCode(); 88 } 89 return hashCode; 90 } 91 }