2 import java.lang.UnsupportedOperationException;
4 import java.util.HashMap;
5 import java.util.HashSet;
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
18 * @author Rahmadi Trimananda <rahmadi.trimananda @ uci.edu>
22 public final class IoTRelation<K, V> {
25 * Reference to an object Map<T>
27 private Map<K,HashSet<V> > mapRelation;
31 * Class constructor (pass the reference to this immutable wrapper)
33 protected IoTRelation(Map<K,HashSet<V>> mapRel, int _iSize) {
39 * Method containsKey() inherited from Map interface
41 * @param key The first Object that is usually a key in a Map
44 public boolean containsKey(K key) {
46 return mapRelation.containsKey(key);
51 * Method entrySet() inherited from Map interface
53 * @return Set<Map.Entry<K,HashSet<V>>>
55 public Set<Map.Entry<K,HashSet<V>>> entrySet() {
57 return new HashSet<Map.Entry<K,HashSet<V>>>(mapRelation.entrySet());
62 * Method keySet() inherited from Map interface
66 public Set<K> keySet() {
68 return new HashSet<K>(mapRelation.keySet());
73 * Method get() inherited from Map interface
75 * @param key The first Object that is usually a key in a Map
78 public HashSet<V> get(K key) {
80 return new HashSet<V>(mapRelation.get(key));
85 * Method isEmpty() inherited from Map interface
89 public boolean isEmpty() {
91 return mapRelation.isEmpty();