(int id, T object)
| 38 | } |
| 39 | |
| 40 | public <T> void addObject(int id, T object) |
| 41 | { |
| 42 | Integer integer = dataTypes.get(object.getClass()); |
| 43 | |
| 44 | if (integer == null) |
| 45 | { |
| 46 | throw new IllegalArgumentException("Unknown data type: " + object.getClass()); |
| 47 | } |
| 48 | else if (id > 31) |
| 49 | { |
| 50 | throw new IllegalArgumentException("Data value id is too big with " + id + "! (Max is " + 31 + ")"); |
| 51 | } |
| 52 | else if (this.watchedObjects.containsKey(id)) |
| 53 | { |
| 54 | throw new IllegalArgumentException("Duplicate id value for " + id + "!"); |
| 55 | } |
| 56 | else |
| 57 | { |
| 58 | DataWatcher.WatchableObject datawatcher$watchableobject = new DataWatcher.WatchableObject(integer, id, object); |
| 59 | this.lock.writeLock().lock(); |
| 60 | this.watchedObjects.put(id, datawatcher$watchableobject); |
| 61 | this.lock.writeLock().unlock(); |
| 62 | this.isBlank = false; |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Add a new object for the DataWatcher to watch, using the specified data type. |
no test coverage detected