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

com.urbanairship.api.customevents.parse.CustomEventUserReader Maven / Gradle / Ivy

package com.urbanairship.api.customevents.parse;


import com.fasterxml.jackson.core.JsonParser;
import com.urbanairship.api.common.parse.APIParsingException;
import com.urbanairship.api.common.parse.JsonObjectReader;
import com.urbanairship.api.customevents.model.CustomEventChannelType;
import com.urbanairship.api.customevents.model.CustomEventUser;

import java.io.IOException;

public class CustomEventUserReader implements JsonObjectReader {

    private final CustomEventUser.Builder builder;

    public CustomEventUserReader() {
        builder = CustomEventUser.newBuilder();
    }

    public void readChannel(CustomEventChannelType type, JsonParser parser) throws IOException {
        builder.setCustomEventChannelType(type);
        builder.setChannel(parser.getText());
    }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy