use of org.eclipse.leshan.core.node.codec.CodecException in project leshan by eclipse.
the class LwM2mNodeTlvDecoder method parseTlvValues.
private static Map<Integer, Object> parseTlvValues(Tlv[] tlvs, Type expectedType, LwM2mPath path) throws CodecException {
Map<Integer, Object> values = new HashMap<>();
for (Tlv tlvChild : tlvs) {
if (tlvChild.getType() != TlvType.RESOURCE_INSTANCE)
throw new CodecException("Expected TLV of type RESOURCE_INSTANCE but was %s for path %s", tlvChild.getType().name(), path);
Object resourceInstance = parseTlvValue(tlvChild.getValue(), expectedType, path);
Object previousResourceInstance = values.put(tlvChild.getIdentifier(), resourceInstance);
if (previousResourceInstance != null) {
throw new CodecException("2 RESOURCE_INSTANCE (%s,%s) with the same identifier %d for path %s", previousResourceInstance, resourceInstance, tlvChild.getIdentifier(), path);
}
}
return values;
}
Aggregations