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

com.urbanairship.api.client.parse.APIScheduleResponseReader Maven / Gradle / Ivy

/*
 * Copyright 2013 Urban Airship and Contributors
 */

package com.urbanairship.api.client.parse;

import com.urbanairship.api.client.APIScheduleResponse;
import com.urbanairship.api.common.parse.JsonObjectReader;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.type.TypeReference;

import java.io.IOException;
import java.util.List;

/*
Readers are the part of the deserialization process that actually builds and
return an object.
 */
public class APIScheduleResponseReader implements JsonObjectReader  {

    private final APIScheduleResponse.Builder builder;

    public APIScheduleResponseReader (){
        this.builder = APIScheduleResponse.newBuilder();
    }

    public void readOperationId(JsonParser jsonParser) throws IOException {
        builder.setOperationId(jsonParser.readValueAs(String.class));
    }

    public void readScheduleIds(JsonParser jsonParser) throws IOException {
        List list =
                jsonParser.readValueAs(new TypeReference>(){});
        builder.setScheduleUrls(list);
    }

    @Override
    public APIScheduleResponse validateAndBuild() throws IOException {
        try{
            return builder.build();
        }
        catch (Exception ex){
            throw new APIParsingException(ex.getMessage());
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy