1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.openehealth.ipf.commons.ihe.xds.core.requests.query;
17
18 import lombok.EqualsAndHashCode;
19 import lombok.Getter;
20 import lombok.ToString;
21
22 import javax.xml.bind.annotation.XmlAccessType;
23 import javax.xml.bind.annotation.XmlAccessorType;
24 import javax.xml.bind.annotation.XmlType;
25 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
26 import java.io.Serializable;
27 import java.util.ArrayList;
28 import java.util.Collections;
29 import java.util.List;
30
31 import static org.apache.commons.lang3.Validate.noNullElements;
32 import static org.apache.commons.lang3.Validate.notNull;
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47 @XmlAccessorType(XmlAccessType.FIELD)
48 @XmlType(name = "QueryList")
49 @EqualsAndHashCode(doNotUseGetters = true)
50 @ToString(doNotUseGetters = true)
51 public class QueryList<T> implements Serializable {
52 private static final long serialVersionUID = -2729640243221349924L;
53
54 @XmlJavaTypeAdapter(ListOfListAdapter.class)
55 @Getter private List<List<T>> outerList = new ArrayList<>();
56
57
58
59
60 public QueryList() {}
61
62
63
64
65
66
67
68
69 public QueryList(QueryList<T> other) {
70 notNull(other, "other cannot be null");
71 noNullElements(other.getOuterList(), "other.getOuterList() cannot contain null elements");
72 for (List<T> innerList : other.getOuterList()) {
73 noNullElements(innerList, "innerList cannot contain null elements");
74 outerList.add(new ArrayList<>(innerList));
75 }
76 }
77
78
79
80
81
82
83 public QueryList(T singleElement) {
84 notNull(singleElement, "singleElement cannot be null");
85 outerList.add(Collections.singletonList(singleElement));
86 }
87
88 }