All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.notronix.etsy.impl.json.ListingStateAdapter Maven / Gradle / Ivy

There is a newer version: 3.0.0014
Show newest version
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