1 package iotruntime.slave;
3 import java.lang.UnsupportedOperationException;
5 import java.util.HashMap;
6 import java.util.HashSet;
11 /** Class IoTRelation is the actual implementation of @config IoTRelation<...>.
12 * Upon extracting DB information, RelationInstrumenter class will use
13 * this class to actually instantiate the Map as IoTRelation uses a
14 * combination between a HashMap and a IoTSet; we don't provide interfaces
15 * to modify the contents, but we do provide means to read them out.
16 * The add method is just used the first time it is needed to add new objects,
17 * then it is going to be made immutable
19 * @author Rahmadi Trimananda <rahmadi.trimananda @ uci.edu>
23 public final class IoTRelation<K, V> {
26 * Reference to an object Map<T>
28 private Map<K,HashSet<V> > mapRelation;
32 * Class constructor (pass the reference to this immutable wrapper)
34 protected IoTRelation(Map<K,HashSet<V>> mapRel, int _iSize) {
40 * Method containsKey() inherited from Map interface
42 * @param key The first Object that is usually a key in a Map
45 public boolean containsKey(K key) {
47 return mapRelation.containsKey(key);
52 * Method entrySet() inherited from Map interface
54 * @return Set<Map.Entry<K,HashSet<V>>>
56 public Set<Map.Entry<K,HashSet<V>>> entrySet() {
58 return new HashSet<Map.Entry<K,HashSet<V>>>(mapRelation.entrySet());
63 * Method keySet() inherited from Map interface
67 public Set<K> keySet() {
69 return new HashSet<K>(mapRelation.keySet());
74 * Method get() inherited from Map interface
76 * @param key The first Object that is usually a key in a Map
79 public HashSet<V> get(K key) {
81 return new HashSet<V>(mapRelation.get(key));
86 * Method isEmpty() inherited from Map interface
90 public boolean isEmpty() {
92 return mapRelation.isEmpty();