View Javadoc
1   /*
2    * Copyright 2008-2009 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.map;
17  
18  import java.util.Collection;
19  import java.util.Set;
20  
21  /**
22   * Interface for mapping a set of keysets into corresponding values.
23   * <p>
24   * The back end mapping implementation is not defined by this interface. Examples
25   * could be a simple {@link java.util.Map} or a remote terminology service, for
26   * which proper implementations of this interface must be provided.
27   * <p> 
28   * 
29   * @author Christian Ohr
30   *
31   */
32  public interface MappingService {
33  
34  	/**
35  	 * @param mappingKey mapping name
36  	 * @param key left side of the mapping
37  	 * @return the value mapped by a registered mapping. The implementation of the
38  	 *         mapping implements the behavior if the key does not exist.
39  	 * @throws IllegalArgumentException
40  	 *             if the mappingKey is not registered.
41  	 */
42  	Object get(Object mappingKey, Object key);
43  
44  	/**
45  	 * @param mappingKey mapping name
46  	 * @param key left side of the mapping
47  	 * @param defaultValue default right side if there is no mapping for the code
48  	 * @return the value mapped by a registered mapping. If no mapping exists, the
49  	 *         default value if returned. The implementation of the mapping
50  	 *         implements the behavior if the key does not exist.
51  	 * @throws IllegalArgumentException
52  	 *             if the mappingKey is not registered.
53  	 */
54  	Object get(Object mappingKey, Object key, Object defaultValue);
55  
56  	/**
57  	 * Reverse mapping (Optional implementation)
58  	 * 
59  	 * @param mappingKey mapping name
60  	 * @param value right side of the mapping
61  	 * @return the key mapped by a registered mapping. The implementation of the
62  	 *         mapping implements the behavior if the value does not exist.
63  	 * @throws IllegalArgumentException
64  	 *             if the mappingKey is not registered.
65  	 */
66  	Object getKey(Object mappingKey, Object value);
67  
68  	/**
69  	 * Reverse mapping (Optional implementation)
70  	 * 
71  	 * @param mappingKey mapping name
72  	 * @param value right side of the mapping
73  	 * @param defaultKey default left side
74  	 * @return the key mapped by a registered mapping. If no mapping exists, the
75  	 *         default value if returned. The implementation of the mapping
76  	 *         implements the behavior if the key does not exist.
77  	 * @throws IllegalArgumentException
78  	 *             if the mappingKey is not registered.
79  	 */
80  	Object getKey(Object mappingKey, Object value, Object defaultKey);
81  	
82  	/**
83  	 * @param mappingKey mapping name
84  	 * @return a formal identification of the key system (e.g. an OID)
85  	 * @throws IllegalArgumentException
86  	 *             if the mappingKey is not registered.
87  	 */
88  	Object getKeySystem(Object mappingKey);
89  
90  	/**
91  	 * @param mappingKey mapping name
92  	 * @return a formal identification of the value system (e.g. an OID)
93  	 * @throws IllegalArgumentException
94  	 *             if the mappingKey is not registered.
95  	 */
96  	Object getValueSystem(Object mappingKey);
97  
98  	/**
99  	 * @return a set of names of all registered mappings. Changes to the set do
100 	 *         not change the registry itself.
101 	 */
102 	Set<?> mappingKeys();
103 
104 	/**
105 	 * @param mappingKey mapping key
106 	 * @return key set of a registered mapping. Changes to the set do not change
107 	 *         the registry itself.
108 	 * @throws IllegalArgumentException
109 	 *             if the mappingKey is not registered.
110 	 */
111 	Set<?> keys(Object mappingKey);
112 
113 	/**
114 	 * @param mappingKey mapping key
115 	 * @return value set of a registered mapping. Changes to the set do not
116 	 *         change the registry itself.
117 	 * @throws IllegalArgumentException
118 	 *             if the mappingKey is not registered.
119 	 */
120 	Collection<?> values(Object mappingKey);
121 
122 }