in sdk-java/src/main/java/com/spotify/confidence/ConfidenceUtils.java [19:51]
static ConfidenceValue getValueForPath(List<String> path, ConfidenceValue fullValue)
throws ValueNotFound {
ConfidenceValue value = fullValue;
for (String fieldName : path) {
final Struct structure = value.asStruct();
if (structure == null) {
// value's inner object actually is no structure
log.warn(
"Illegal attempt to derive field '{}' on non-structure value '{}'", fieldName, value);
throw new ValueNotFound(
String.format(
"Illegal attempt to derive field '%s' on non-structure value '%s'",
fieldName, value));
}
value = structure.get(fieldName);
if (value == null) {
// we know that null indicates absence of a proper value because intended nulls would be an
// instance of type Value
log.warn(
"Illegal attempt to derive non-existing field '{}' on structure value '{}'",
fieldName,
structure);
throw new ValueNotFound(
String.format(
"Illegal attempt to derive non-existing field '%s' on structure value '%s'",
fieldName, structure));
}
}
return value;
}