001 package org.apache.maven.scm.provider.accurev;
002
003 /*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements. See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership. The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License. You may obtain a copy of the License at
011 *
012 * http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied. See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022
023 import java.io.File;
024
025 public class FileDifference
026 {
027
028 private String oldVersionSpec = null;
029
030 private File oldFile = null;
031
032 private String newVersionSpec = null;
033
034 private File newFile = null;
035
036 private long elementId = -1;
037
038 public FileDifference( long elementId, String newPath, String newVersion, String oldPath, String oldVersion )
039 {
040 setElementId( elementId );
041 setNewVersion( newPath, newVersion );
042 setOldVersion( oldPath, oldVersion );
043 }
044
045 public FileDifference()
046 {
047
048 }
049
050 public String getOldVersionSpec()
051 {
052 return oldVersionSpec;
053 }
054
055 public File getOldFile()
056 {
057 return oldFile;
058 }
059
060 public String getNewVersionSpec()
061 {
062 return newVersionSpec;
063 }
064
065 public File getNewFile()
066 {
067 return newFile;
068 }
069
070 public long getElementId()
071 {
072 return elementId;
073 }
074
075 public void setElementId( long elementId )
076 {
077 this.elementId = elementId;
078 }
079
080 public void setNewVersion( String path, String version )
081 {
082
083 this.newFile =
084 ( oldFile != null && oldFile.getPath().equals( path ) ) ? oldFile : path == null ? null : new File( path );
085 this.newVersionSpec = version;
086
087 }
088
089 public void setOldVersion( String path, String version )
090 {
091
092 this.oldFile =
093 ( newFile != null && newFile.getPath().equals( path ) ) ? newFile : path == null ? null : new File( path );
094 this.oldVersionSpec = version;
095
096 }
097
098 @Override
099 public String toString()
100 {
101 return "FileDifference [elementId=" + elementId + ", newFile=" + newFile + ", newVersionSpec=" + newVersionSpec
102 + ", oldFile=" + oldFile + ", oldVersionSpec=" + oldVersionSpec + "]";
103 }
104
105 @Override
106 public int hashCode()
107 {
108 final int prime = 31;
109 int result = 1;
110 result = prime * result + (int) ( elementId ^ ( elementId >>> 32 ) );
111 result = prime * result + ( ( newFile == null ) ? 0 : newFile.hashCode() );
112 result = prime * result + ( ( newVersionSpec == null ) ? 0 : newVersionSpec.hashCode() );
113 result = prime * result + ( ( oldFile == null ) ? 0 : oldFile.hashCode() );
114 result = prime * result + ( ( oldVersionSpec == null ) ? 0 : oldVersionSpec.hashCode() );
115 return result;
116 }
117
118 @Override
119 public boolean equals( Object obj )
120 {
121 if ( this == obj )
122 return true;
123 if ( obj == null )
124 return false;
125 if ( getClass() != obj.getClass() )
126 return false;
127 FileDifference other = (FileDifference) obj;
128 if ( elementId != other.elementId )
129 return false;
130 if ( newFile == null )
131 {
132 if ( other.newFile != null )
133 return false;
134 }
135 else if ( !newFile.equals( other.newFile ) )
136 return false;
137 if ( newVersionSpec == null )
138 {
139 if ( other.newVersionSpec != null )
140 return false;
141 }
142 else if ( !newVersionSpec.equals( other.newVersionSpec ) )
143 return false;
144 if ( oldFile == null )
145 {
146 if ( other.oldFile != null )
147 return false;
148 }
149 else if ( !oldFile.equals( other.oldFile ) )
150 return false;
151 if ( oldVersionSpec == null )
152 {
153 if ( other.oldVersionSpec != null )
154 return false;
155 }
156 else if ( !oldVersionSpec.equals( other.oldVersionSpec ) )
157 return false;
158 return true;
159 }
160
161 }