com.oneops.gslb.domain.AutoValue_Fqdn Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gslb Show documentation
Show all versions of gslb Show documentation
Library for managing gslb
package com.oneops.gslb.domain;
import com.google.gson.Gson;
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.lang.Override;
import java.lang.String;
final class AutoValue_Fqdn extends $AutoValue_Fqdn {
AutoValue_Fqdn(String aliasesJson, String fullAliasesJson, String distribution) {
super(aliasesJson, fullAliasesJson, distribution);
}
public static final class GsonTypeAdapter extends TypeAdapter {
private final TypeAdapter aliasesJsonAdapter;
private final TypeAdapter fullAliasesJsonAdapter;
private final TypeAdapter distributionAdapter;
private String defaultAliasesJson = null;
private String defaultFullAliasesJson = null;
private String defaultDistribution = null;
public GsonTypeAdapter(Gson gson) {
this.aliasesJsonAdapter = gson.getAdapter(String.class);
this.fullAliasesJsonAdapter = gson.getAdapter(String.class);
this.distributionAdapter = gson.getAdapter(String.class);
}
public GsonTypeAdapter setDefaultAliasesJson(String defaultAliasesJson) {
this.defaultAliasesJson = defaultAliasesJson;
return this;
}
public GsonTypeAdapter setDefaultFullAliasesJson(String defaultFullAliasesJson) {
this.defaultFullAliasesJson = defaultFullAliasesJson;
return this;
}
public GsonTypeAdapter setDefaultDistribution(String defaultDistribution) {
this.defaultDistribution = defaultDistribution;
return this;
}
@Override
public void write(JsonWriter jsonWriter, Fqdn object) throws IOException {
if (object == null) {
jsonWriter.nullValue();
return;
}
jsonWriter.beginObject();
jsonWriter.name("aliasesJson");
aliasesJsonAdapter.write(jsonWriter, object.aliasesJson());
jsonWriter.name("fullAliasesJson");
fullAliasesJsonAdapter.write(jsonWriter, object.fullAliasesJson());
jsonWriter.name("distribution");
distributionAdapter.write(jsonWriter, object.distribution());
jsonWriter.endObject();
}
@Override
public Fqdn read(JsonReader jsonReader) throws IOException {
if (jsonReader.peek() == JsonToken.NULL) {
jsonReader.nextNull();
return null;
}
jsonReader.beginObject();
String aliasesJson = this.defaultAliasesJson;
String fullAliasesJson = this.defaultFullAliasesJson;
String distribution = this.defaultDistribution;
while (jsonReader.hasNext()) {
String _name = jsonReader.nextName();
switch (_name) {
case "aliasesJson": {
aliasesJson = aliasesJsonAdapter.read(jsonReader);
break;
}
case "fullAliasesJson": {
fullAliasesJson = fullAliasesJsonAdapter.read(jsonReader);
break;
}
case "distribution": {
distribution = distributionAdapter.read(jsonReader);
break;
}
default: {
jsonReader.skipValue();
}
}
}
jsonReader.endObject();
return new AutoValue_Fqdn(aliasesJson, fullAliasesJson, distribution);
}
}
}