com.notronix.etsy.impl.json.ListingStateAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of JEtsy Show documentation
Show all versions of JEtsy Show documentation
A Java implementation of a Java version of the Etsy API
package com.notronix.etsy.impl.json;
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter;
import com.notronix.etsy.api.model.ListingState;
import java.io.IOException;
public class ListingStateAdapter extends TypeAdapter
{
@Override
public void write(JsonWriter out, ListingState value) throws IOException {
out.value(value.apiValue());
}
@Override
public ListingState read(JsonReader in) throws IOException {
JsonToken token = in.peek();
if (token == JsonToken.STRING) {
return ListingState.forValue(in.nextString());
}
throw new IOException("Expected STRING but was " + token.name() + ". Path: " + in.getPath());
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy