![JAR search and dependency download from the Maven repository](/logo.png)
com.oneops.infoblox.model.AutoValue_Error Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of infoblox-java Show documentation
Show all versions of infoblox-java Show documentation
A pure java API for Infoblox DNS appliance.
package com.oneops.infoblox.model;
import com.squareup.moshi.JsonAdapter;
import com.squareup.moshi.JsonReader;
import com.squareup.moshi.JsonWriter;
import com.squareup.moshi.Moshi;
import java.io.IOException;
import java.lang.Override;
import java.lang.String;
import java.lang.reflect.Type;
final class AutoValue_Error extends $AutoValue_Error {
AutoValue_Error(String error, String code, String text, String trace) {
super(error, code, text, trace);
}
public static final class MoshiJsonAdapter extends JsonAdapter {
private static final String[] NAMES = new String[] {"Error","code","text","trace"};
private static final JsonReader.Options OPTIONS = JsonReader.Options.of(NAMES);
private final JsonAdapter errorAdapter;
private final JsonAdapter codeAdapter;
private final JsonAdapter textAdapter;
private final JsonAdapter traceAdapter;
public MoshiJsonAdapter(Moshi moshi) {
this.errorAdapter = adapter(moshi, String.class);
this.codeAdapter = adapter(moshi, String.class);
this.textAdapter = adapter(moshi, String.class);
this.traceAdapter = adapter(moshi, String.class).nullSafe();
}
@Override
public Error fromJson(JsonReader reader) throws IOException {
reader.beginObject();
String error = null;
String code = null;
String text = null;
String trace = null;
while (reader.hasNext()) {
switch (reader.selectName(OPTIONS)) {
case 0: {
error = this.errorAdapter.fromJson(reader);
break;
}
case 1: {
code = this.codeAdapter.fromJson(reader);
break;
}
case 2: {
text = this.textAdapter.fromJson(reader);
break;
}
case 3: {
trace = this.traceAdapter.fromJson(reader);
break;
}
case -1: {
// Unknown name, skip it
reader.nextName();
reader.skipValue();
}
}
}
reader.endObject();
return new AutoValue_Error(error, code, text, trace);
}
@Override
public void toJson(JsonWriter writer, Error value) throws IOException {
writer.beginObject();
writer.name("Error");
this.errorAdapter.toJson(writer, value.error());
writer.name("code");
this.codeAdapter.toJson(writer, value.code());
writer.name("text");
this.textAdapter.toJson(writer, value.text());
String trace = value.trace();
if (trace != null) {
writer.name("trace");
this.traceAdapter.toJson(writer, trace);
}
writer.endObject();
}
private JsonAdapter adapter(Moshi moshi, Type adapterType) {
return moshi.adapter(adapterType);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy