Minor fixes in LifxLightBulb driver (not fully tested yet)
[iot2.git] / iotjava / iotruntime / slave / ISet.java
1 package iotruntime.slave;
2
3 import java.io.Serializable;
4
5 import java.lang.UnsupportedOperationException;
6
7 import java.util.Collection;
8 import java.util.HashSet;
9 import java.util.Iterator;
10 import java.util.Set;
11 import java.util.Spliterator;
12
13
14 /** Class ISet is another wrapper class of IoTSet that is the
15  *  actual implementation of @config IoTSet<...>.
16  *  The function is the same as the IoTSet class, but this class
17  *  is meant for the class instrumenter to have full access to
18  *  our class object. The IoTSet class functions as an immutable
19  *  interface to clients/users.
20  *
21  * @author      Rahmadi Trimananda <rahmadi.trimananda @ uci.edu>
22  * @version     1.0
23  * @since       2016-01-05
24  */
25 public final class ISet<T> implements Serializable {
26
27         /**
28          * Reference to an object Set<T>
29          */
30         private Set<T> set;
31
32         /**
33          * Empty class constructor
34          */
35         protected ISet() {
36
37                 set = new HashSet<T>();
38         }
39
40         /**
41          * Class constructor (pass the reference to this mutable wrapper)
42          */
43         protected ISet(Set<T> s) {
44
45                 set = s;
46         }
47
48         /**
49          * add() method inherited from Set interface
50          */
51         public boolean add(T o) {
52
53                 return set.add(o);
54
55         }
56
57         /**
58          * clear() method inherited from Set interface
59          */
60         public void clear() {
61
62                 set.clear();
63
64         }
65
66         /**
67          * contains() method inherited from Set interface
68          */
69         public boolean contains(Object o) {
70
71                 return set.contains(o);
72
73         }
74
75         /**
76          * isEmpty() method inherited from Set interface
77          */
78         public boolean isEmpty() {
79
80                 return set.isEmpty();
81
82         }
83
84         /**
85          * iterator() method inherited from Set interface
86          */
87         public Iterator<T> iterator() {
88
89                 return set.iterator();
90
91         }
92
93         /**
94          * remove() method inherited from Set interface
95          */
96         public boolean remove(Object o) {
97
98                 return set.remove(o);
99
100         }
101
102         /**
103          * size() method inherited from Set interface
104          */
105         public int size() {
106
107                 return set.size();
108
109         }
110
111         /**
112          * values() method to return Set object values for easy iteration
113          */
114         public Set<T> values() {
115
116                 return set;
117
118         }
119 }