com.google.api.services.plus.model.Comment

Here are the examples of the java api class com.google.api.services.plus.model.Comment taken from open source projects.

1. GooglePlusActivityUtil#updateActivity()

View license
/**
     * Given a {@link List} of {@link com.google.api.services.plus.model.Comment} objects and an
     * {@link org.apache.streams.pojo.json.Activity}, update that Activity to contain all comments
     *
     * @param comments
     * @param activity
     */
public static void updateActivity(List<Comment> comments, Activity activity) {
    for (Comment comment : comments) {
        addComment(activity, comment);
    }
    Map<String, Object> extensions = ensureExtensions(activity);
    extensions.put("comment_count", comments.size());
}

2. GPlusCommentDeserializer#deserialize()

View license
/**
     * Because the GooglePlus Comment object {@link com.google.api.services.plus.model.Comment} contains complex objects
     * within its hierarchy, we have to use a custom deserializer
     *
     * @param jsonParser
     * @param deserializationContext
     * @return The deserialized {@link com.google.api.services.plus.model.Comment} object
     * @throws java.io.IOException
     * @throws com.fasterxml.jackson.core.JsonProcessingException
     */
@Override
public Comment deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
    JsonNode node = jsonParser.getCodec().readTree(jsonParser);
    ObjectMapper objectMapper = StreamsJacksonMapper.getInstance();
    Comment comment = new Comment();
    try {
        comment.setEtag(node.get("etag").asText());
        comment.setVerb(node.get("verb").asText());
        comment.setId(node.get("id").asText());
        comment.setPublished(DateTime.parseRfc3339(node.get("published").asText()));
        comment.setUpdated(DateTime.parseRfc3339(node.get("updated").asText()));
        Comment.Actor actor = new Comment.Actor();
        JsonNode actorNode = node.get("actor");
        actor.setDisplayName(actorNode.get("displayName").asText());
        actor.setUrl(actorNode.get("url").asText());
        Comment.Actor.Image image = new Comment.Actor.Image();
        JsonNode imageNode = actorNode.get("image");
        image.setUrl(imageNode.get("url").asText());
        actor.setImage(image);
        comment.setObject(objectMapper.readValue(objectMapper.writeValueAsString(node.get("object")), Comment.PlusObject.class));
        comment.setSelfLink(node.get("selfLink").asText());
        List<Comment.InReplyTo> replies = Lists.newArrayList();
        for (JsonNode reply : node.get("inReplyTo")) {
            Comment.InReplyTo r = objectMapper.readValue(objectMapper.writeValueAsString(reply), Comment.InReplyTo.class);
            replies.add(r);
        }
        comment.setInReplyTo(replies);
        Comment.Plusoners plusoners = new Comment.Plusoners();
        JsonNode plusonersNode = node.get("plusoners");
        plusoners.setTotalItems(plusonersNode.get("totalItems").asLong());
        comment.setPlusoners(plusoners);
    } catch (Exception e) {
        LOGGER.error("Exception while trying to deserialize activity object: {}", e);
    }
    return comment;
}