com.oneops.gslb.mtd.v2.domain.AutoValue_SqlNullString 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.mtd.v2.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.Boolean;
import java.lang.Override;
import java.lang.String;
final class AutoValue_SqlNullString extends $AutoValue_SqlNullString {
AutoValue_SqlNullString(String string, Boolean valid) {
super(string, valid);
}
public static final class GsonTypeAdapter extends TypeAdapter {
private final TypeAdapter stringAdapter;
private final TypeAdapter validAdapter;
private String defaultString = null;
private Boolean defaultValid = null;
public GsonTypeAdapter(Gson gson) {
this.stringAdapter = gson.getAdapter(String.class);
this.validAdapter = gson.getAdapter(Boolean.class);
}
public GsonTypeAdapter setDefaultString(String defaultString) {
this.defaultString = defaultString;
return this;
}
public GsonTypeAdapter setDefaultValid(Boolean defaultValid) {
this.defaultValid = defaultValid;
return this;
}
@Override
public void write(JsonWriter jsonWriter, SqlNullString object) throws IOException {
if (object == null) {
jsonWriter.nullValue();
return;
}
jsonWriter.beginObject();
jsonWriter.name("String");
stringAdapter.write(jsonWriter, object.string());
jsonWriter.name("Valid");
validAdapter.write(jsonWriter, object.valid());
jsonWriter.endObject();
}
@Override
public SqlNullString read(JsonReader jsonReader) throws IOException {
if (jsonReader.peek() == JsonToken.NULL) {
jsonReader.nextNull();
return null;
}
jsonReader.beginObject();
String string = this.defaultString;
Boolean valid = this.defaultValid;
while (jsonReader.hasNext()) {
String _name = jsonReader.nextName();
switch (_name) {
case "String": {
string = stringAdapter.read(jsonReader);
break;
}
case "Valid": {
valid = validAdapter.read(jsonReader);
break;
}
default: {
jsonReader.skipValue();
}
}
}
jsonReader.endObject();
return new AutoValue_SqlNullString(string, valid);
}
}
}