1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package no.sintef.assetrepository;
22
23 import java.io.Serializable;
24 import java.util.ArrayList;
25 import java.util.Collection;
26 import java.util.Collections;
27
28 import no.sintef.assetrepository.interfaces.AssetVersionPK;
29
30 /***
31 * @author fvr
32 *
33 * TODO To change the template for this generated type comment go to
34 * Window - Preferences - Java - Code Style - Code Templates
35 */
36 public class VersionHistory implements Serializable {
37
38 private AssetVersionPK rootVersion;
39 private Collection versions;
40
41 public VersionHistory() {
42 this(null, new ArrayList());
43 }
44
45 /***
46 * @param rootVersion
47 * @param versions
48 */
49 public VersionHistory(AssetVersionPK rootVersion, Collection versions) {
50 this.rootVersion = rootVersion;
51 this.versions = versions;
52 }
53
54 public AssetVersionPK getRootVersion() {
55 return rootVersion;
56 }
57 public void setRootVersion(AssetVersionPK rootVersion) {
58 this.rootVersion = rootVersion;
59 }
60
61 public Collection getVersions() {
62 return Collections.unmodifiableCollection(versions);
63 }
64 public void addVersion(AssetVersionPK newVersion) {
65 versions.add(newVersion);
66 }
67 public void removeVersion(AssetVersionPK oldVersion) {
68 versions.remove(oldVersion);
69 }
70
71 public boolean equals(Object obj) {
72 if (obj instanceof VersionHistory) {
73 boolean equals = true;
74 VersionHistory other = (VersionHistory) obj;
75 equals &= (rootVersion == other.rootVersion ||
76 (rootVersion != null && rootVersion.equals(other.rootVersion)));
77 equals &= (versions == other.versions ||
78 (versions != null && versions.equals(other.versions)));
79 return equals;
80 } else {
81 return false;
82 }
83 }
84 public int hashCode() {
85 int result = 0;
86 result += 37 * (rootVersion != null ? rootVersion.hashCode() : 0);
87 result += 37 * (versions != null ? versions.hashCode() : 0);
88 return result;
89 }
90
91 }