
com.neotys.neoload.model.v3.project.scenario.GsonAdaptersDynatraceAnomalyRule Maven / Gradle / Ivy
package com.neotys.neoload.model.v3.project.scenario;
import com.google.gson.*;
import com.google.gson.reflect.*;
import com.google.gson.stream.*;
import java.io.IOException;
import javax.annotation.Generated;
import javax.annotation.ParametersAreNonnullByDefault;
/**
* A {@code TypeAdapterFactory} that handles all of the immutable types generated under {@code DynatraceAnomalyRule}.
* @see ImmutableDynatraceAnomalyRule
*/
@SuppressWarnings("all")
@Generated({"Gsons.generator", "com.neotys.neoload.model.v3.project.scenario.DynatraceAnomalyRule"})
@ParametersAreNonnullByDefault
public final class GsonAdaptersDynatraceAnomalyRule implements TypeAdapterFactory {
@SuppressWarnings({"unchecked", "raw"}) // safe unchecked, types are verified in runtime
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (DynatraceAnomalyRuleTypeAdapter.adapts(type)) {
return (TypeAdapter) new DynatraceAnomalyRuleTypeAdapter(gson);
}
return null;
}
@Override
public String toString() {
return "GsonAdaptersDynatraceAnomalyRule(DynatraceAnomalyRule)";
}
@SuppressWarnings({"unchecked", "raw"}) // safe unchecked, types are verified in runtime
private static class DynatraceAnomalyRuleTypeAdapter extends TypeAdapter {
DynatraceAnomalyRuleTypeAdapter(Gson gson) {
}
static boolean adapts(TypeToken> type) {
return DynatraceAnomalyRule.class == type.getRawType()
|| ImmutableDynatraceAnomalyRule.class == type.getRawType();
}
@Override
public void write(JsonWriter out, DynatraceAnomalyRule value) throws IOException {
if (value == null) {
out.nullValue();
} else {
writeDynatraceAnomalyRule(out, value);
}
}
@Override
public DynatraceAnomalyRule read(JsonReader in) throws IOException {
if (in.peek() == JsonToken.NULL) {
in.nextNull();
return null;
}
return readDynatraceAnomalyRule(in);
}
private void writeDynatraceAnomalyRule(JsonWriter out, DynatraceAnomalyRule instance)
throws IOException {
out.beginObject();
String metricIdValue = instance.getMetricId();
if (metricIdValue != null) {
out.name("metricId");
out.value(metricIdValue);
} else if (out.getSerializeNulls()) {
out.name("metricId");
out.nullValue();
}
String operatorValue = instance.getOperator();
if (operatorValue != null) {
out.name("operator");
out.value(operatorValue);
} else if (out.getSerializeNulls()) {
out.name("operator");
out.nullValue();
}
String valueValue = instance.getValue();
if (valueValue != null) {
out.name("value");
out.value(valueValue);
} else if (out.getSerializeNulls()) {
out.name("value");
out.nullValue();
}
String severityValue = instance.getSeverity();
if (severityValue != null) {
out.name("severity");
out.value(severityValue);
} else if (out.getSerializeNulls()) {
out.name("severity");
out.nullValue();
}
out.endObject();
}
private DynatraceAnomalyRule readDynatraceAnomalyRule(JsonReader in)
throws IOException {
DynatraceAnomalyRule.Builder builder = new DynatraceAnomalyRule.Builder();
in.beginObject();
while (in.hasNext()) {
eachAttribute(in, builder);
}
in.endObject();
return builder.build();
}
private void eachAttribute(JsonReader in, DynatraceAnomalyRule.Builder builder)
throws IOException {
String attributeName = in.nextName();
switch (attributeName.charAt(0)) {
case 'm':
if ("metricId".equals(attributeName)) {
readInMetricId(in, builder);
return;
}
break;
case 'o':
if ("operator".equals(attributeName)) {
readInOperator(in, builder);
return;
}
break;
case 'v':
if ("value".equals(attributeName)) {
readInValue(in, builder);
return;
}
break;
case 's':
if ("severity".equals(attributeName)) {
readInSeverity(in, builder);
return;
}
break;
default:
}
in.skipValue();
}
private void readInMetricId(JsonReader in, DynatraceAnomalyRule.Builder builder)
throws IOException {
if (in.peek() == JsonToken.NULL) {
in.nextNull();
} else {
builder.metricId(in.nextString());
}
}
private void readInOperator(JsonReader in, DynatraceAnomalyRule.Builder builder)
throws IOException {
if (in.peek() == JsonToken.NULL) {
in.nextNull();
} else {
builder.operator(in.nextString());
}
}
private void readInValue(JsonReader in, DynatraceAnomalyRule.Builder builder)
throws IOException {
if (in.peek() == JsonToken.NULL) {
in.nextNull();
} else {
builder.value(in.nextString());
}
}
private void readInSeverity(JsonReader in, DynatraceAnomalyRule.Builder builder)
throws IOException {
if (in.peek() == JsonToken.NULL) {
in.nextNull();
} else {
builder.severity(in.nextString());
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy