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
|
/*******************************************************************************
* Copyright (c) 2004, 2007 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.change;
import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.model.TransactionDelta;
import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
/**
* @author Roberto E. Escobar
*/
public class ArtifactDelta {
private final Artifact startArt;
private final Artifact endArt;
private final Artifact baseArt;
private final TransactionDelta txDelta;
public ArtifactDelta(TransactionDelta txDelta, Artifact startArt, Artifact endArt) throws OseeArgumentException {
if (startArt == null && endArt == null) {
throw new OseeArgumentException("the start and end artifacts can not both be null.");
}
this.startArt = startArt;
this.endArt = endArt;
this.baseArt = startArt;
this.txDelta = txDelta;
}
public ArtifactDelta(TransactionDelta txDelta, Artifact startArt, Artifact endArt, Artifact baseArt) throws OseeArgumentException {
if (startArt == null && endArt == null) {
throw new OseeArgumentException("the start and end artifacts can not both be null.");
}
this.startArt = startArt;
this.endArt = endArt;
this.baseArt = baseArt;
this.txDelta = txDelta;
}
public ArtifactDelta(Artifact startArt, Artifact endArt) throws OseeArgumentException {
this(null, startArt, endArt);
}
public TransactionDelta getTxDelta() {
return txDelta;
}
public Artifact getStartArtifact() {
return startArt;
}
public Artifact getEndArtifact() {
return endArt;
}
public Artifact getBaseArtifact() {
return baseArt;
}
public IOseeBranch getBranch() {
return getStartArtifact() != null ? getStartArtifact().getBranchToken() : getEndArtifact().getBranchToken();
}
@Override
public boolean equals(Object obj) {
boolean result = false;
if (obj instanceof ArtifactDelta) {
ArtifactDelta other = (ArtifactDelta) obj;
boolean left = startArt == null ? other.startArt == null : startArt.equals(other.startArt);
boolean right = endArt == null ? other.endArt == null : endArt.equals(other.endArt);
result = left && right;
}
return result;
}
@Override
public int hashCode() {
final int prime = 37;
int result = 17;
if (startArt != null) {
result = prime * result + startArt.hashCode();
} else {
result = prime * result;
}
if (endArt != null) {
result = prime * result + endArt.hashCode();
} else {
result = prime * result;
}
return result;
}
@Override
public String toString() {
String firstString = String.valueOf(getStartArtifact());
String secondString = String.valueOf(getEndArtifact());
return String.format("[start:%s, end:%s]", firstString, secondString);
}
}
|