+
+ public <T> T extractValueByPathUsingAdditionalProperties (List<String> keys, Class<T> clazz) {
+ Object result = getAdditionalProperties();
+ for (String key : keys) {
+ if (result instanceof Map) {
+ result = ((Map) result).get(key);
+ }
+
+ else {
+ throw new NotFoundException("failed to find key: "+key+" in path: "+String.join("\\", keys));
+ }
+ }
+ if (clazz.isInstance(result)) {
+ return clazz.cast(result);
+ }
+
+ throw new NotFoundException(
+ String.format("failed to extract value from path:%s because %s is not of type %s",
+ String.join("\\", keys), String.valueOf(result) , clazz));
+ }
+
+