1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
/*******************************************************************************
* Copyright (c) 2010 Boeing.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
package org.eclipse.osee.framework.skynet.core.event.model;
import org.eclipse.osee.framework.core.model.event.DefaultBasicGuidArtifact;
import org.eclipse.osee.framework.core.model.event.DefaultBasicGuidRelation;
import org.eclipse.osee.framework.skynet.core.relation.RelationEventType;
/**
* @author Donald G. Dunne
*/
public class EventBasicGuidRelation extends DefaultBasicGuidRelation {
private final RelationEventType relationEventType;
private final int artAId;
private final int artBId;
private String rationale;
public EventBasicGuidRelation(RelationEventType relationEventType, int artAId, int artBId, DefaultBasicGuidRelation guidRel) {
this(relationEventType, guidRel.getBranchGuid(), guidRel.getRelTypeGuid(), guidRel.getRelationId(),
guidRel.getGammaId(), artAId, guidRel.getArtA(), artBId, guidRel.getArtB());
}
public EventBasicGuidRelation(RelationEventType relationEventType, String branchGuid, String relTypeGuid, int relationId, int gammaId, int artAId, DefaultBasicGuidArtifact artA, int artBId, DefaultBasicGuidArtifact artB) {
super(branchGuid, relTypeGuid, relationId, gammaId, artA, artB);
this.relationEventType = relationEventType;
this.artAId = artAId;
this.artBId = artBId;
}
public RelationEventType getModType() {
return relationEventType;
}
@Override
public String toString() {
return String.format("[%s - B:%s - TG:%s - GI:%d - RI:%d - A:%s - B:%s]", relationEventType, getBranchGuid(),
getBranchGuid(), getGammaId(), getRelationId(), getArtA(), getArtB());
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + (relationEventType == null ? 0 : relationEventType.hashCode());
result = prime * result + artAId;
result = prime * result + (getArtA() == null ? 0 : getArtA().hashCode());
result = prime * result + artBId;
result = prime * result + (getArtB() == null ? 0 : getArtB().hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!super.equals(obj)) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
EventBasicGuidRelation other = (EventBasicGuidRelation) obj;
if (relationEventType == null) {
if (other.relationEventType != null) {
return false;
}
} else if (!relationEventType.equals(other.relationEventType)) {
return false;
}
if (artAId != other.artAId) {
return false;
}
if (getArtA() == null) {
if (other.getArtA() != null) {
return false;
}
} else if (!getArtA().equals(other.getArtA())) {
return false;
}
if (artBId != other.artBId) {
return false;
}
if (getArtB() == null) {
if (other.getArtB() != null) {
return false;
}
} else if (!getArtB().equals(other.getArtB())) {
return false;
}
return true;
}
public int getArtAId() {
return artAId;
}
public int getArtBId() {
return artBId;
}
public String getRationale() {
return rationale;
}
public void setRationale(String rationale) {
this.rationale = rationale;
}
public boolean is(RelationEventType... relationEventTypes) {
for (RelationEventType eventModType : relationEventTypes) {
if (this.relationEventType == eventModType) {
return true;
}
}
return false;
}
}
|