1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package org.modeshape.connector.store.jpa.model.basic;
25
26 import java.io.Serializable;
27 import javax.persistence.Column;
28 import javax.persistence.Embeddable;
29 import net.jcip.annotations.Immutable;
30 import org.modeshape.common.util.HashCode;
31
32
33
34
35
36 @Embeddable
37 @Immutable
38 @org.hibernate.annotations.Immutable
39 public class ReferenceId implements Serializable {
40
41
42
43
44 private static final long serialVersionUID = 1L;
45
46 @Column( name = "WORKSPACE_ID", nullable = false )
47 private Long workspaceId;
48
49 @Column( name = "FROM_UUID", nullable = false, updatable = false, length = 36 )
50 private String fromUuidString;
51
52 @Column( name = "TO_UUID", nullable = false, updatable = false, length = 36 )
53 private String toUuidString;
54
55 public ReferenceId() {
56 }
57
58 public ReferenceId( Long workspaceId,
59 String fromUuid,
60 String toUuid ) {
61 this.workspaceId = workspaceId;
62 this.fromUuidString = fromUuid;
63 this.toUuidString = toUuid;
64 }
65
66
67
68
69 public String getFromUuidString() {
70 return fromUuidString;
71 }
72
73
74
75
76 public String getToUuidString() {
77 return toUuidString;
78 }
79
80
81
82
83 public Long getWorkspaceId() {
84 return workspaceId;
85 }
86
87
88
89
90
91
92 @Override
93 public int hashCode() {
94 return HashCode.compute(fromUuidString, toUuidString);
95 }
96
97
98
99
100
101
102 @Override
103 public boolean equals( Object obj ) {
104 if (obj == this) return true;
105 if (obj instanceof ReferenceId) {
106 ReferenceId that = (ReferenceId)obj;
107 if (this.workspaceId == null) {
108 if (that.workspaceId != null) return false;
109 } else {
110 if (!this.workspaceId.equals(that.workspaceId)) return false;
111 }
112 if (this.fromUuidString == null) {
113 if (that.fromUuidString != null) return false;
114 } else {
115 if (!this.fromUuidString.equals(that.fromUuidString)) return false;
116 }
117 if (this.toUuidString == null) {
118 if (that.toUuidString != null) return false;
119 } else {
120 if (!this.toUuidString.equals(that.toUuidString)) return false;
121 }
122 return true;
123 }
124 return false;
125 }
126
127
128
129
130
131
132 @Override
133 public String toString() {
134 return "Reference from " + fromUuidString + " to " + toUuidString + " in workspace " + workspaceId;
135 }
136
137 }