1 package org.apache.maven.scm.provider.accurev;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23
24
25
26
27 public class FileDifference
28 {
29
30 private String oldVersionSpec = null;
31
32 private File oldFile = null;
33
34 private String newVersionSpec = null;
35
36 private File newFile = null;
37
38 private long elementId = -1;
39
40 public FileDifference( long elementId, String newPath, String newVersion, String oldPath, String oldVersion )
41 {
42 setElementId( elementId );
43 setNewVersion( newPath, newVersion );
44 setOldVersion( oldPath, oldVersion );
45 }
46
47 public FileDifference()
48 {
49
50 }
51
52 public String getOldVersionSpec()
53 {
54 return oldVersionSpec;
55 }
56
57 public File getOldFile()
58 {
59 return oldFile;
60 }
61
62 public String getNewVersionSpec()
63 {
64 return newVersionSpec;
65 }
66
67 public File getNewFile()
68 {
69 return newFile;
70 }
71
72 public long getElementId()
73 {
74 return elementId;
75 }
76
77 public void setElementId( long elementId )
78 {
79 this.elementId = elementId;
80 }
81
82 public void setNewVersion( String path, String version )
83 {
84
85 this.newFile =
86 ( oldFile != null && oldFile.getPath().equals( path ) ) ? oldFile : path == null ? null : new File( path );
87 this.newVersionSpec = version;
88
89 }
90
91 public void setOldVersion( String path, String version )
92 {
93
94 this.oldFile =
95 ( newFile != null && newFile.getPath().equals( path ) ) ? newFile : path == null ? null : new File( path );
96 this.oldVersionSpec = version;
97
98 }
99
100 @Override
101 public String toString()
102 {
103 return "FileDifference [elementId=" + elementId + ", newFile=" + newFile + ", newVersionSpec=" + newVersionSpec
104 + ", oldFile=" + oldFile + ", oldVersionSpec=" + oldVersionSpec + "]";
105 }
106
107 @Override
108 public int hashCode()
109 {
110 final int prime = 31;
111 int result = 1;
112 result = prime * result + (int) ( elementId ^ ( elementId >>> 32 ) );
113 result = prime * result + ( ( newFile == null ) ? 0 : newFile.hashCode() );
114 result = prime * result + ( ( newVersionSpec == null ) ? 0 : newVersionSpec.hashCode() );
115 result = prime * result + ( ( oldFile == null ) ? 0 : oldFile.hashCode() );
116 result = prime * result + ( ( oldVersionSpec == null ) ? 0 : oldVersionSpec.hashCode() );
117 return result;
118 }
119
120 @Override
121 public boolean equals( Object obj )
122 {
123 if ( this == obj )
124 {
125 return true;
126 }
127 if ( obj == null )
128 {
129 return false;
130 }
131 if ( getClass() != obj.getClass() )
132 {
133 return false;
134 }
135 FileDifference other = (FileDifference) obj;
136 if ( elementId != other.elementId )
137 {
138 return false;
139 }
140 if ( newFile == null )
141 {
142 if ( other.newFile != null )
143 {
144 return false;
145 }
146 }
147 else if ( !newFile.equals( other.newFile ) )
148 {
149 return false;
150 }
151 if ( newVersionSpec == null )
152 {
153 if ( other.newVersionSpec != null )
154 {
155 return false;
156 }
157 }
158 else if ( !newVersionSpec.equals( other.newVersionSpec ) )
159 {
160 return false;
161 }
162 if ( oldFile == null )
163 {
164 if ( other.oldFile != null )
165 {
166 return false;
167 }
168 }
169 else if ( !oldFile.equals( other.oldFile ) )
170 {
171 return false;
172 }
173 if ( oldVersionSpec == null )
174 {
175 if ( other.oldVersionSpec != null )
176 {
177 return false;
178 }
179 }
180 else if ( !oldVersionSpec.equals( other.oldVersionSpec ) )
181 {
182 return false;
183 }
184 return true;
185 }
186
187 }