com.neotys.neoload.model.v3.project.scenario.GsonAdaptersCustomPolicyStep 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.ParametersAreNonnullByDefault;
import javax.annotation.processing.Generated;
/**
* A {@code TypeAdapterFactory} that handles all of the immutable types generated under {@code CustomPolicyStep}.
* @see ImmutableCustomPolicyStep
*/
@SuppressWarnings({"all", "MethodCanBeStatic"})
@ParametersAreNonnullByDefault
@Generated("org.immutables.processor.ProxyProcessor")
@org.immutables.value.Generated(from = "com.neotys.neoload.model.v3.project.scenario", generator = "Gsons")
public final class GsonAdaptersCustomPolicyStep implements TypeAdapterFactory {
@SuppressWarnings({"unchecked", "rawtypes"}) // safe unchecked, types are verified in runtime
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (CustomPolicyStepTypeAdapter.adapts(type)) {
return (TypeAdapter) new CustomPolicyStepTypeAdapter(gson);
}
return null;
}
@Override
public String toString() {
return "GsonAdaptersCustomPolicyStep(CustomPolicyStep)";
}
@org.immutables.value.Generated(from = "CustomPolicyStep", generator = "Gsons")
@SuppressWarnings({"unchecked", "rawtypes"}) // safe unchecked, types are verified in runtime
private static class CustomPolicyStepTypeAdapter extends TypeAdapter {
public final LoadDuration whenTypeSample = null;
public final Integer usersTypeSample = null;
private final TypeAdapter whenTypeAdapter;
private final TypeAdapter usersTypeAdapter;
CustomPolicyStepTypeAdapter(Gson gson) {
this.whenTypeAdapter = gson.getAdapter( LoadDuration.class);
this.usersTypeAdapter = gson.getAdapter( Integer.class);
}
static boolean adapts(TypeToken> type) {
return CustomPolicyStep.class == type.getRawType()
|| ImmutableCustomPolicyStep.class == type.getRawType();
}
@Override
public void write(JsonWriter out, CustomPolicyStep value) throws IOException {
if (value == null) {
out.nullValue();
} else {
writeCustomPolicyStep(out, value);
}
}
@Override
public CustomPolicyStep read(JsonReader in) throws IOException {
return readCustomPolicyStep(in);
}
private void writeCustomPolicyStep(JsonWriter out, CustomPolicyStep instance)
throws IOException {
out.beginObject();
LoadDuration whenValue = instance.getWhen();
if (whenValue != null) {
out.name("when");
whenTypeAdapter.write(out, whenValue);
} else if (out.getSerializeNulls()) {
out.name("when");
out.nullValue();
}
Integer usersValue = instance.getUsers();
if (usersValue != null) {
out.name("users");
usersTypeAdapter.write(out, usersValue);
} else if (out.getSerializeNulls()) {
out.name("users");
out.nullValue();
}
out.endObject();
}
private CustomPolicyStep readCustomPolicyStep(JsonReader in)
throws IOException {
if (in.peek() == JsonToken.NULL) {
in.nextNull();
return null;
}
CustomPolicyStep.Builder builder = new CustomPolicyStep.Builder();
in.beginObject();
while (in.hasNext()) {
eachAttribute(in, builder);
}
in.endObject();
return builder.build();
}
private void eachAttribute(JsonReader in, CustomPolicyStep.Builder builder)
throws IOException {
String attributeName = in.nextName();
switch (attributeName.charAt(0)) {
case 'w':
if ("when".equals(attributeName)) {
readInWhen(in, builder);
return;
}
break;
case 'u':
if ("users".equals(attributeName)) {
readInUsers(in, builder);
return;
}
break;
default:
}
in.skipValue();
}
private void readInWhen(JsonReader in, CustomPolicyStep.Builder builder)
throws IOException {
if (in.peek() == JsonToken.NULL) {
in.nextNull();
} else {
LoadDuration value = whenTypeAdapter.read(in);
builder.when(value);
}
}
private void readInUsers(JsonReader in, CustomPolicyStep.Builder builder)
throws IOException {
if (in.peek() == JsonToken.NULL) {
in.nextNull();
} else {
Integer value = usersTypeAdapter.read(in);
builder.users(value);
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy