org.immutables.fixture.GsonAdaptersHeaderCopy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of value-fixture Show documentation
Show all versions of value-fixture Show documentation
Module that contains all tests for the code generation capability
// HEADER COPY TEST
//
/* Copyright
*
*
*/
/**
*
*/
package org.immutables.fixture;
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 HeaderCopy}.
* @see ImmutableHeaderCopy
*/
@SuppressWarnings({"all", "MethodCanBeStatic"})
@ParametersAreNonnullByDefault
@Generated("org.immutables.processor.ProxyProcessor")
@org.immutables.value.Generated(from = "org.immutables.fixture", generator = "Gsons")
public final class GsonAdaptersHeaderCopy implements TypeAdapterFactory {
@SuppressWarnings({"unchecked", "rawtypes"}) // safe unchecked, types are verified in runtime
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (HeaderCopyTypeAdapter.adapts(type)) {
return (TypeAdapter) new HeaderCopyTypeAdapter(gson);
}
return null;
}
@Override
public String toString() {
return "GsonAdaptersHeaderCopy(HeaderCopy)";
}
@org.immutables.value.Generated(from = "HeaderCopy", generator = "Gsons")
@SuppressWarnings({"unchecked", "rawtypes"}) // safe unchecked, types are verified in runtime
private static class HeaderCopyTypeAdapter extends TypeAdapter {
HeaderCopyTypeAdapter(Gson gson) {}
static boolean adapts(TypeToken> type) {
return HeaderCopy.class == type.getRawType()
|| ImmutableHeaderCopy.class == type.getRawType();
}
@Override
public void write(JsonWriter out, HeaderCopy value) throws IOException {
if (value == null) {
out.nullValue();
} else {
writeHeaderCopy(out, value);
}
}
@Override
public HeaderCopy read(JsonReader in) throws IOException {
return readHeaderCopy(in);
}
private void writeHeaderCopy(JsonWriter out, HeaderCopy instance)
throws IOException {
out.beginObject();
out.endObject();
}
private static HeaderCopy readHeaderCopy(JsonReader in)
throws IOException {
if (in.peek() == JsonToken.NULL) {
in.nextNull();
return null;
}
ImmutableHeaderCopy.Builder builder = ImmutableHeaderCopy.builder();
in.skipValue();
return builder.build();
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy