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

ch.viascom.hipchat.api.deserializer.MessageFromDeserializer Maven / Gradle / Ivy

There is a newer version: 2.1-RC3
Show newest version
package ch.viascom.hipchat.api.deserializer;

import ch.viascom.hipchat.api.models.message.MessageFrom;
import com.google.gson.*;

import java.lang.reflect.Type;

/**
 * Created by patrickboesch on 21.04.16.
 */
public class MessageFromDeserializer implements JsonDeserializer {

    @Override
    public MessageFrom deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {

        MessageFrom messageFrom = new MessageFrom();
        if (jsonElement.isJsonObject()) {
            messageFrom = new Gson().fromJson(jsonElement, MessageFrom.class);
        } else {
            messageFrom.setName(jsonElement.getAsString());
        }

        return messageFrom;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy