org.immutables.fixture.nested.GsonAdaptersInnerNested Maven / Gradle / Ivy
package org.immutables.fixture.nested;
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 InnerNested}.
* @see ImmutableInnerNested.Nested
* @see ImmutableInnerNested.Inner
* @see ImmutableInnerNested
*/
@SuppressWarnings("all")
@Generated({"Gsons.generator", "org.immutables.fixture.nested.InnerNested"})
@ParametersAreNonnullByDefault
public final class GsonAdaptersInnerNested implements TypeAdapterFactory {
@SuppressWarnings({"unchecked", "raw"}) // safe unchecked, types are verified in runtime
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (NestedTypeAdapter.adapts(type)) {
return (TypeAdapter) new NestedTypeAdapter(gson);
}
if (InnerTypeAdapter.adapts(type)) {
return (TypeAdapter) new InnerTypeAdapter(gson);
}
if (InnerNestedTypeAdapter.adapts(type)) {
return (TypeAdapter) new InnerNestedTypeAdapter(gson);
}
return null;
}
@Override
public String toString() {
return "GsonAdaptersInnerNested(Nested, Inner, InnerNested)";
}
@SuppressWarnings({"unchecked", "raw"}) // safe unchecked, types are verified in runtime
private static class NestedTypeAdapter extends TypeAdapter {
NestedTypeAdapter(Gson gson) {}
static boolean adapts(TypeToken> type) {
return InnerNested.Nested.class == type.getRawType()
|| ImmutableInnerNested.Nested.class == type.getRawType();
}
@Override
public void write(JsonWriter out, InnerNested.Nested value) throws IOException {
if (value == null) {
out.nullValue();
} else {
writeNested(out, value);
}
}
@Override
public InnerNested.Nested read(JsonReader in) throws IOException {
if (in.peek() == JsonToken.NULL) {
in.nextNull();
return null;
}
return readNested(in);
}
private void writeNested(JsonWriter out, InnerNested.Nested instance)
throws IOException {
out.beginObject();
out.endObject();
}
private InnerNested.Nested readNested(JsonReader in)
throws IOException {
ImmutableInnerNested.Nested.Builder builder = ImmutableInnerNested.Nested.builder();
in.skipValue();
return builder.build();
}
}
@SuppressWarnings({"unchecked", "raw"}) // safe unchecked, types are verified in runtime
private static class InnerTypeAdapter extends TypeAdapter {
InnerTypeAdapter(Gson gson) {}
static boolean adapts(TypeToken> type) {
return InnerNested.Inner.class == type.getRawType()
|| ImmutableInnerNested.Inner.class == type.getRawType();
}
@Override
public void write(JsonWriter out, InnerNested.Inner value) throws IOException {
if (value == null) {
out.nullValue();
} else {
writeInner(out, value);
}
}
@Override
public InnerNested.Inner read(JsonReader in) throws IOException {
if (in.peek() == JsonToken.NULL) {
in.nextNull();
return null;
}
return readInner(in);
}
private void writeInner(JsonWriter out, InnerNested.Inner instance)
throws IOException {
out.beginObject();
out.endObject();
}
private InnerNested.Inner readInner(JsonReader in)
throws IOException {
ImmutableInnerNested.Inner.Builder builder = ImmutableInnerNested.Inner.builder();
in.skipValue();
return builder.build();
}
}
@SuppressWarnings({"unchecked", "raw"}) // safe unchecked, types are verified in runtime
private static class InnerNestedTypeAdapter extends TypeAdapter {
InnerNestedTypeAdapter(Gson gson) {}
static boolean adapts(TypeToken> type) {
return InnerNested.class == type.getRawType()
|| ImmutableInnerNested.class == type.getRawType();
}
@Override
public void write(JsonWriter out, InnerNested value) throws IOException {
if (value == null) {
out.nullValue();
} else {
writeInnerNested(out, value);
}
}
@Override
public InnerNested read(JsonReader in) throws IOException {
if (in.peek() == JsonToken.NULL) {
in.nextNull();
return null;
}
return readInnerNested(in);
}
private void writeInnerNested(JsonWriter out, InnerNested instance)
throws IOException {
out.beginObject();
out.endObject();
}
private InnerNested readInnerNested(JsonReader in)
throws IOException {
ImmutableInnerNested.Builder builder = ImmutableInnerNested.builder();
in.skipValue();
return builder.build();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy