com.urbanairship.api.segments.parse.SegmentViewReader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-client Show documentation
Show all versions of java-client Show documentation
The Urban Airship Java client library
package com.urbanairship.api.segments.parse;
import com.fasterxml.jackson.core.JsonParser;
import com.urbanairship.api.common.model.ErrorDetails;
import com.urbanairship.api.common.parse.APIParsingException;
import com.urbanairship.api.common.parse.JsonObjectReader;
import com.urbanairship.api.push.model.audience.Selector;
import com.urbanairship.api.segments.model.SegmentView;
import java.io.IOException;
public class SegmentViewReader implements JsonObjectReader {
private final SegmentView.Builder builder;
public SegmentViewReader() {
this.builder = SegmentView.newBuilder();
}
public void readCriteria(JsonParser jsonParser) throws IOException {
builder.setCriteria(jsonParser.readValueAs(Selector.class));
}
public void readDisplayName(JsonParser jsonParser) throws IOException {
builder.setDisplayName(jsonParser.readValueAs(String.class));
}
public void readError(JsonParser jsonParser) throws IOException {
builder.setError(jsonParser.readValueAs(String.class));
}
public void readErrorDetails(JsonParser jsonParser) throws IOException {
builder.setErrorDetails(jsonParser.readValueAs(ErrorDetails.class));
}
@Override
public SegmentView validateAndBuild() throws IOException {
try {
return builder.build();
} catch (Exception ex) {
throw new APIParsingException(ex.getMessage());
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy