com.urbanairship.api.push.parse.notification.web.WebDevicePayloadDeserializer 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.push.parse.notification.web;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableMap;
import com.urbanairship.api.common.parse.FieldParser;
import com.urbanairship.api.common.parse.FieldParserRegistry;
import com.urbanairship.api.common.parse.MapFieldParserRegistry;
import com.urbanairship.api.common.parse.StandardObjectDeserializer;
import com.urbanairship.api.push.model.notification.web.WebDevicePayload;
import java.io.IOException;
public class WebDevicePayloadDeserializer extends JsonDeserializer {
private static final FieldParserRegistry FIELD_PARSER = new MapFieldParserRegistry(
ImmutableMap.>builder()
.put("alert", new FieldParser() {
public void parse(WebDevicePayloadReader reader, JsonParser json, DeserializationContext context) throws IOException {
reader.readAlert(json);
}
})
.put("title", new FieldParser() {
public void parse(WebDevicePayloadReader reader, JsonParser json, DeserializationContext context) throws IOException {
reader.readTitle(json);
}
})
.put("extra", new FieldParser() {
public void parse(WebDevicePayloadReader reader, JsonParser json, DeserializationContext context) throws IOException {
reader.readExtra(json);
}
})
.put("icon", new FieldParser() {
public void parse(WebDevicePayloadReader reader, JsonParser json, DeserializationContext context) throws IOException {
reader.readWebIcon(json);
}
})
.put("require_interaction", new FieldParser() {
public void parse(WebDevicePayloadReader reader, JsonParser json, DeserializationContext context) throws IOException {
reader.readRequireInteraction(json);
}
})
.put("actions", new FieldParser() {
@Override
public void parse(WebDevicePayloadReader reader, JsonParser json, DeserializationContext context) throws IOException {
reader.readActions(json);
}
})
.put("image", new FieldParser() {
@Override
public void parse(WebDevicePayloadReader reader, JsonParser json, DeserializationContext context) throws IOException {
reader.readWebImage(json);
}
})
.put("time_to_live", new FieldParser() {
@Override
public void parse(WebDevicePayloadReader reader, JsonParser json, DeserializationContext context) throws IOException {
reader.readExpiry(json);
}
})
.put("buttons", new FieldParser() {
@Override
public void parse(WebDevicePayloadReader reader, JsonParser json, DeserializationContext context) throws IOException {
reader.readButtons(json);
}
})
.put("template", new FieldParser() {
@Override
public void parse(WebDevicePayloadReader reader, JsonParser json, DeserializationContext context) throws IOException {
reader.readTemplate(json);
}
})
.build()
);
private final StandardObjectDeserializer deserializer;
public WebDevicePayloadDeserializer() {
deserializer = new StandardObjectDeserializer(
FIELD_PARSER,
new Supplier() {
@Override
public WebDevicePayloadReader get() {
return new WebDevicePayloadReader();
}
}
);
}
@Override
public WebDevicePayload deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
return deserializer.deserialize(jp, ctxt);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy