1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package ca.uhn.hl7v2.testpanel.util.compare;
23
24 import java.util.ArrayList;
25 import java.util.Collections;
26 import java.util.List;
27
28 import ca.uhn.hl7v2.HL7Exception;
29 import ca.uhn.hl7v2.model.Group;
30 import ca.uhn.hl7v2.model.Segment;
31 import ca.uhn.hl7v2.model.Structure;
32
33 public class ExtraGroup extends StructureComparison {
34
35
36 private Group myGroup;
37 private boolean myMessage1;
38
39
40
41 public ExtraGroup(Group theGroup, boolean theMessage1) {
42 myGroup = theGroup;
43 myMessage1 = theMessage1;
44 }
45
46
47
48 private List<SegmentComparison> flatten(Structure theStructure) {
49 if (theStructure instanceof Segment) {
50 if (myMessage1) {
51 return Collections.singletonList((SegmentComparisonil/compare/SegmentComparison.html#SegmentComparison">SegmentComparison) new SegmentComparison(
52 theStructure.getName(),
53 (Segment) theStructure,
54 null));
55 } else {
56 return Collections.singletonList((SegmentComparisonil/compare/SegmentComparison.html#SegmentComparison">SegmentComparison) new SegmentComparison(
57 theStructure.getName(),
58 null,
59 (Segment) theStructure));
60 }
61 }
62
63 ArrayList<SegmentComparison> retVal = new ArrayList<SegmentComparison>();
64 Group="../../../../../../ca/uhn/hl7v2/model/Group.html#Group">Group group = (Group) theStructure;
65
66 for (String nextName : group.getNames()) {
67 try {
68 for (Structure nextRep : group.getAll(nextName)) {
69 retVal.addAll(flatten(nextRep));
70 }
71 } catch (HL7Exception e) {
72 throw new Error(e);
73 }
74 }
75
76 return retVal;
77 }
78
79 @Override
80 public List<SegmentComparison> flattenMessage() {
81 return flatten(myGroup);
82 }
83
84 public Group getGroup() {
85 return myGroup;
86 }
87
88 public boolean isMessage1() {
89 return myMessage1;
90 }
91 }