1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.openehealth.ipf.commons.ihe.xds.core.validate.query;
17
18 import static org.apache.commons.lang3.Validate.notNull;
19
20 import org.openehealth.ipf.commons.ihe.xds.core.ebxml.EbXMLAdhocQueryRequest;
21 import org.openehealth.ipf.commons.ihe.xds.core.transform.requests.QueryParameter;
22 import org.openehealth.ipf.commons.ihe.xds.core.transform.requests.query.QuerySlotHelper;
23 import org.openehealth.ipf.commons.ihe.xds.core.validate.ValueValidator;
24 import org.openehealth.ipf.commons.ihe.xds.core.validate.XDSMetaDataException;
25
26
27
28
29
30 public class NumberValidation implements QueryParameterValidation {
31 private final QueryParameter param;
32 private final ValueValidator validator;
33
34
35
36
37
38
39
40
41 public NumberValidation(QueryParameter param, ValueValidator validator) {
42 notNull(param, "param cannot be null");
43 notNull(validator, "validator cannot be null");
44
45 this.param = param;
46 this.validator = validator;
47 }
48
49 @Override
50 public void validate(EbXMLAdhocQueryRequest request) throws XDSMetaDataException {
51 QuerySlotHelper slots = new QuerySlotHelper(request);
52 String value = slots.toNumber(param);
53 if (value != null) {
54 validator.validate(value);
55 }
56 }
57 }