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
23 import java.io.File;
24
25 public class FileDifference
26 {
27
28 private String oldVersionSpec = null;
29
30 private File oldFile = null;
31
32 private String newVersionSpec = null;
33
34 private File newFile = null;
35
36 private long elementId = -1;
37
38 public FileDifference( long elementId, String newPath, String newVersion, String oldPath, String oldVersion )
39 {
40 setElementId( elementId );
41 setNewVersion( newPath, newVersion );
42 setOldVersion( oldPath, oldVersion );
43 }
44
45 public FileDifference()
46 {
47
48 }
49
50 public String getOldVersionSpec()
51 {
52 return oldVersionSpec;
53 }
54
55 public File getOldFile()
56 {
57 return oldFile;
58 }
59
60 public String getNewVersionSpec()
61 {
62 return newVersionSpec;
63 }
64
65 public File getNewFile()
66 {
67 return newFile;
68 }
69
70 public long getElementId()
71 {
72 return elementId;
73 }
74
75 public void setElementId( long elementId )
76 {
77 this.elementId = elementId;
78 }
79
80 public void setNewVersion( String path, String version )
81 {
82
83 this.newFile =
84 ( oldFile != null && oldFile.getPath().equals( path ) ) ? oldFile : path == null ? null : new File( path );
85 this.newVersionSpec = version;
86
87 }
88
89 public void setOldVersion( String path, String version )
90 {
91
92 this.oldFile =
93 ( newFile != null && newFile.getPath().equals( path ) ) ? newFile : path == null ? null : new File( path );
94 this.oldVersionSpec = version;
95
96 }
97
98 @Override
99 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 }