Embeded Benchmark
[iotcloud.git] / version2 / src / java / light_fan_embed_benchmark / IoTSet.java
diff --git a/version2/src/java/light_fan_embed_benchmark/IoTSet.java b/version2/src/java/light_fan_embed_benchmark/IoTSet.java
new file mode 100644 (file)
index 0000000..ccf8543
--- /dev/null
@@ -0,0 +1,79 @@
+import java.lang.UnsupportedOperationException;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.Spliterator;
+
+
+/** Class IoTSet is the actual implementation of @config IoTSet<...>.
+ *  Upon extracting DB information, SetInstrumenter class will use
+ *  this class to actually instantiate the Set as IoTSet that uses
+ *  Java Set<T> to implement; we don't provide interfaces to modify
+ *  the contents, but we do provide means to read them out
+ *
+ * @author      Rahmadi Trimananda <rahmadi.trimananda @ uci.edu>
+ * @version     1.0
+ * @since       2015-12-01
+ */
+public final class IoTSet<T> {
+
+       /**
+        * Reference to an object Set<T>
+        */
+       private Set<T> set;
+
+       /**
+        * Class constructor (pass the reference to this immutable wrapper)
+        */
+       protected IoTSet(Set<T> s) {
+
+               set = s;
+       }
+
+       /**
+        * contains() method inherited from Set interface
+        */
+       public boolean contains(T o) {
+
+               return set.contains(o);
+
+       }
+
+       /**
+        * isEmpty() method inherited from Set interface
+        */
+       public boolean isEmpty() {
+
+               return set.isEmpty();
+
+       }
+
+       /**
+        * iterator() method inherited from Set interface
+        */
+       public Iterator<T> iterator() {
+
+               return new HashSet<T>(set).iterator();
+
+       }
+
+       /**
+        * size() method inherited from Set interface
+        */
+       public int size() {
+
+               return set.size();
+
+       }
+
+       /**
+        * values() method to return Set object values for easy iteration
+        */
+       public Set<T> values() {
+
+               return new HashSet<T>(set);
+
+       }
+}