instances[i] = context.deserialize(array.get(i), LwM2mNode.class); node = new LwM2mObject(id, instances);
node = new LwM2mObject(baseName.getObjectId(), instances); } else if (nodeClass == LwM2mObjectInstance.class) {
@Override protected ReadResponse doRead(ServerIdentity identity, ReadRequest request) { LwM2mPath path = request.getPath(); // Manage Object case if (path.isObject()) { List<LwM2mObjectInstance> lwM2mObjectInstances = new ArrayList<>(); for (Entry<Integer, LwM2mInstanceEnabler> entry : instances.entrySet()) { lwM2mObjectInstances.add(getLwM2mObjectInstance(entry.getKey(), entry.getValue(), identity, false)); } return ReadResponse.success(new LwM2mObject(getId(), lwM2mObjectInstances)); } // Manage Instance case LwM2mInstanceEnabler instance = instances.get(path.getObjectInstanceId()); if (instance == null) return ReadResponse.notFound(); if (path.getResourceId() == null) { return ReadResponse.success(getLwM2mObjectInstance(path.getObjectInstanceId(), instance, identity, false)); } // Manage Resource case return instance.read(path.getResourceId()); }
@Override protected ObserveResponse doObserve(final ServerIdentity identity, final ObserveRequest request) { final LwM2mPath path = request.getPath(); // Manage Object case if (path.isObject()) { List<LwM2mObjectInstance> lwM2mObjectInstances = new ArrayList<>(); for (Entry<Integer, LwM2mInstanceEnabler> entry : instances.entrySet()) { lwM2mObjectInstances.add(getLwM2mObjectInstance(entry.getKey(), entry.getValue(), identity, true)); } return ObserveResponse.success(new LwM2mObject(getId(), lwM2mObjectInstances)); } // Manage Instance case final LwM2mInstanceEnabler instance = instances.get(path.getObjectInstanceId()); if (instance == null) return ObserveResponse.notFound(); if (path.getResourceId() == null) { return ObserveResponse .success(getLwM2mObjectInstance(path.getObjectInstanceId(), instance, identity, true)); } // Manage Resource case return instance.observe(path.getResourceId()); }
instances.add(instance); return new LwM2mObject(id, instances);
instances.add(instance); return new LwM2mObject(id, instances);
return (T) new LwM2mObject(path.getObjectId(), instances.values());