Github user robdouglas commented on a diff in the pull request:

    https://github.com/apache/incubator-streams/pull/184#discussion_r24848425
  
    --- Diff: 
streams-contrib/streams-provider-youtube/src/main/java/com/youtube/serializer/YoutubeChannelDeserializer.java
 ---
    @@ -0,0 +1,131 @@
    +package com.youtube.serializer;
    +
    +import com.fasterxml.jackson.core.JsonParser;
    +import com.fasterxml.jackson.core.JsonProcessingException;
    +import com.fasterxml.jackson.databind.DeserializationContext;
    +import com.fasterxml.jackson.databind.JsonDeserializer;
    +import com.fasterxml.jackson.databind.JsonNode;
    +import com.google.api.client.util.DateTime;
    +import com.google.api.services.youtube.model.Channel;
    +import com.google.api.services.youtube.model.ChannelContentDetails;
    +import com.google.api.services.youtube.model.ChannelLocalization;
    +import com.google.api.services.youtube.model.ChannelSnippet;
    +import com.google.api.services.youtube.model.ChannelStatistics;
    +import com.google.api.services.youtube.model.ChannelTopicDetails;
    +import com.google.api.services.youtube.model.Thumbnail;
    +import com.google.api.services.youtube.model.ThumbnailDetails;
    +import com.google.common.collect.Lists;
    +
    +import java.io.IOException;
    +import java.util.Iterator;
    +import java.util.List;
    +
    +/**
    + *
    + */
    +public class YoutubeChannelDeserializer extends JsonDeserializer<Channel> {
    +
    +
    +    @Override
    +    public Channel deserialize(JsonParser jp, DeserializationContext ctxt) 
throws IOException, JsonProcessingException {
    +        JsonNode node = jp.getCodec().readTree(jp);
    +        try {
    +            Channel channel = new Channel();
    +            if(node.findPath("etag") != null)
    +                channel.setEtag(node.get("etag").asText());
    +            if(node.findPath("kind") != null)
    +                channel.setKind(node.get("kind").asText());
    +            channel.setId(node.get("id").asText());
    +            
channel.setTopicDetails(setTopicDetails(node.findValue("topicDetails")));
    +            
channel.setStatistics(setChannelStatistics(node.findValue("statistics")));
    +            
channel.setContentDetails(setContentDetails(node.findValue("contentDetails")));
    +            
channel.setSnippet(setChannelSnippet(node.findValue("snippet")));
    +            return channel;
    +        } catch (Throwable t) {
    +            throw new IOException(t);
    +        }
    --- End diff --
    
    Sounds good


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to