Adjusting files in ZigbeeTest; preparing things for 4th benchmark, i.e. generating...
[iot2.git] / benchmarks / other / ZigbeeTest / IoTRelation.java
1
2 import java.lang.UnsupportedOperationException;
3
4 import java.util.HashMap;
5 import java.util.HashSet;
6 import java.util.Map;
7 import java.util.Set;
8
9
10 /** Class IoTRelation is the actual implementation of @config IoTRelation<...>.
11  *  Upon extracting DB information, RelationInstrumenter class will use
12  *  this class to actually instantiate the Map as IoTRelation uses a
13  *  combination between a HashMap and a IoTSet; we don't provide interfaces
14  *  to modify the contents, but we do provide means to read them out.
15  *  The add method is just used the first time it is needed to add new objects,
16  *  then it is going to be made immutable
17  *
18  * @author      Rahmadi Trimananda <rahmadi.trimananda @ uci.edu>
19  * @version     1.0
20  * @since       2015-12-01
21  */
22 public final class IoTRelation<K, V> {
23
24         /**
25          * Reference to an object Map<T>
26          */
27         private Map<K,HashSet<V> > mapRelation;
28         private int iSize;
29
30         /**
31          * Class constructor (pass the reference to this immutable wrapper)
32          */
33         protected IoTRelation(Map<K,HashSet<V>> mapRel, int _iSize) {
34                 mapRelation = mapRel;
35                 iSize = _iSize;
36         }
37
38         /**
39          * Method containsKey() inherited from Map interface
40          *
41          * @param  key  The first Object that is usually a key in a Map
42          * @return      boolean
43          */
44         public boolean containsKey(K key) {
45
46                 return mapRelation.containsKey(key);
47
48         }
49
50         /**
51          * Method entrySet() inherited from Map interface
52          *
53          * @return      Set<Map.Entry<K,HashSet<V>>>
54          */
55         public Set<Map.Entry<K,HashSet<V>>> entrySet() {
56
57                 return new HashSet<Map.Entry<K,HashSet<V>>>(mapRelation.entrySet());
58
59         }
60
61         /**
62          * Method keySet() inherited from Map interface
63          *
64          * @return      Set<K>
65          */
66         public Set<K> keySet() {
67
68                 return new HashSet<K>(mapRelation.keySet());
69
70         }
71
72         /**
73          * Method get() inherited from Map interface
74          *
75          * @param  key  The first Object that is usually a key in a Map
76          * @return      HashSet<V>
77          */
78         public HashSet<V> get(K key) {
79
80                 return new HashSet<V>(mapRelation.get(key));
81
82         }
83
84         /**
85          * Method isEmpty() inherited from Map interface
86          *
87          * @return      boolean
88          */
89         public boolean isEmpty() {
90
91                 return mapRelation.isEmpty();
92
93         }
94
95         /**
96          * size() method
97          *
98          * @return      int
99          */
100         public int size() {
101
102                 return this.iSize;
103
104         }
105 }