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 package ca.uhn.hl7v2.testpanel.util;
27
28 import java.util.List;
29
30 import org.apache.commons.lang.Validate;
31
32 import ca.uhn.hl7v2.model.Segment;
33
34 public class SegmentAndComponentPath {
35
36 private List<Integer> myComponentPath;
37 private int myRepNum = 1;
38 private Segment mySegment;
39
40 public SegmentAndComponentPath(Segment theSegment, List<Integer> theComponentPath) {
41 super();
42
43 Validate.notNull(theSegment);
44 Validate.notNull(theComponentPath);
45 Validate.notEmpty(theComponentPath);
46
47 mySegment = theSegment;
48 myComponentPath = theComponentPath;
49 }
50
51 public SegmentAndComponentPath(Segment theSegment, List<Integer> theComponentPath, int theRepNumber) {
52 this(theSegment, theComponentPath);
53 assert theRepNumber > 0;
54
55 myRepNum = theRepNumber;
56 }
57
58
59
60
61 @Override
62 public boolean equals(Object theObj) {
63 if (theObj == null || !((theObj instanceof SegmentAndComponentPath))) {
64 return false;
65 }
66
67 SegmentAndComponentPath o = (SegmentAndComponentPath) theObj;
68
69 return mySegment == o.mySegment && myComponentPath.equals(o.myComponentPath);
70 }
71
72
73
74
75 public List<Integer> getComponentPath() {
76 return myComponentPath;
77 }
78
79
80
81
82 public int getRepNum() {
83 return myRepNum;
84 }
85
86
87
88
89 public Segment getSegment() {
90 return mySegment;
91 }
92
93
94
95
96 @Override
97 public int hashCode() {
98 return mySegment.hashCode() + myComponentPath.hashCode();
99 }
100
101 }