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

com.urbanairship.api.reports.parse.RichPerPushCountsReader Maven / Gradle / Ivy

There is a newer version: 9.7.0
Show newest version
/*
 * Copyright (c) 2013-2016.  Urban Airship and Contributors
 */

package com.urbanairship.api.reports.parse;

import com.urbanairship.api.common.parse.APIParsingException;
import com.urbanairship.api.common.parse.JsonObjectReader;
import com.urbanairship.api.reports.model.RichPerPushCounts;
import org.codehaus.jackson.JsonParser;

import java.io.IOException;

public final class RichPerPushCountsReader implements JsonObjectReader {

    private final RichPerPushCounts.Builder builder;

    public RichPerPushCountsReader() {
        this.builder = RichPerPushCounts.newBuilder();
    }

    public void readResponses(JsonParser jsonParser) throws IOException {
        builder.setResponses(jsonParser.readValueAs(long.class));
    }

    public void readSends(JsonParser jsonParser) throws IOException {
        builder.setSends(jsonParser.readValueAs(long.class));
    }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy