in openfeature-provider/src/main/java/com/spotify/confidence/OpenFeatureUtils.java [28:46]
static Struct convertToProto(EvaluationContext evaluationContext) {
final Struct.Builder protoEvaluationContext = Struct.newBuilder();
evaluationContext
.asMap()
.forEach(
(mapKey, mapValue) -> {
protoEvaluationContext.putFields(mapKey, OpenFeatureTypeMapper.from(mapValue));
});
// add targeting key as a regular value to proto struct
if (evaluationContext.getTargetingKey() != null
&& !evaluationContext.getTargetingKey().isEmpty()) {
protoEvaluationContext.putFields(
TARGETING_KEY,
com.google.protobuf.Value.newBuilder()
.setStringValue(evaluationContext.getTargetingKey())
.build());
}
return protoEvaluationContext.build();
}