View Javadoc
1   /*
2    * Copyright 2012 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.openehealth.ipf.commons.ihe.xds.core.requests.query;
17  
18  import org.openehealth.ipf.commons.ihe.xds.core.validate.ValidationMessage;
19  import org.openehealth.ipf.commons.ihe.xds.core.validate.XDSMetaDataException;
20  
21  import javax.xml.bind.annotation.XmlEnum;
22  import javax.xml.bind.annotation.XmlEnumValue;
23  import javax.xml.bind.annotation.XmlType;
24  
25  /**
26   * Return types for XDS queries (ITI-18, ITI-38, ITI-51, ITI-63).
27   * @author Dmytro Rud
28   */
29  @XmlType(name = "QueryReturnType")
30  @XmlEnum(String.class)
31  public enum QueryReturnType {
32      // for ITI-18, ITI-38 and ITI-51
33      @XmlEnumValue("LeafClass") LEAF_CLASS("LeafClass"),
34      @XmlEnumValue("ObjectRef") OBJECT_REF("ObjectRef"),
35  
36      // for ITI-63
37      @XmlEnumValue("LeafClassWithRepositoryItem") LEAF_CLASS_WITH_REPOSITORY_ITEM("LeafClassWithRepositoryItem");
38  
39      private final String code;
40  
41      QueryReturnType(String code) {
42          this.code = code;
43      }
44  
45      public String getCode() {
46          return code;
47      }
48  
49      public static QueryReturnType valueOfCode(String code) {
50          for (QueryReturnType type : values()) {
51              if (type.getCode().equals(code)) {
52                  return type;
53              }
54          }
55  
56          throw new XDSMetaDataException(ValidationMessage.WRONG_QUERY_RETURN_TYPE, code);
57      }
58  }