in src/main/java/com/google/cloud/run/kafkascaler/scalingconfig/Metric.java [41:72]
static Metric fromYamlMap(Map<String, Object> input, String resourcePath) {
Metric.Builder builder = new AutoValue_Metric.Builder();
Validation.checkKeyExists(input, "type", resourcePath);
if (input.containsKey("type")) {
switch ((String) input.get("type")) {
case "External":
builder = builder.type(Type.EXTERNAL);
Validation.checkKeyExists(input, "external", resourcePath);
builder =
builder.external(
External.fromYamlMap(
(Map<String, Object>) input.get("external"), resourcePath + ".external"));
break;
case "Resource":
builder = builder.type(Type.RESOURCE);
Validation.checkKeyExists(input, "resource", resourcePath);
builder =
builder.resource(
Resource.fromYamlMap(
(Map<String, Object>) input.get("resource"), resourcePath + ".resource"));
break;
default:
throw new IllegalArgumentException(
String.format("Unsupported %s.type: %s", resourcePath, input.get("type")));
}
}
return builder.build();
}