List of usage examples for org.springframework.social.facebook.api ListAndCount ListAndCount
public ListAndCount(List<T> list, int count)
From source file:org.springframework.social.facebook.api.impl.json.ReferenceListAndCountDeserializer.java
@SuppressWarnings("unchecked") @Override/* www . j a va 2 s .com*/ public ListAndCount<Reference> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new FacebookModule()); jp.setCodec(mapper); if (jp.hasCurrentToken()) { JsonNode node = jp.readValueAs(JsonNode.class); JsonNode dataNode = node.get("data"); List<Reference> commentsList = dataNode != null ? (List<Reference>) mapper.reader(new TypeReference<List<Reference>>() { }).readValue(dataNode) : Collections.<Reference>emptyList(); JsonNode countNode = node.get("count"); int referenceCount = countNode != null ? countNode.intValue() : 0; return new ListAndCount<Reference>(commentsList, referenceCount); } return null; }
From source file:org.springframework.social.facebook.api.impl.json.CommentListAndCountDeserializer.java
@SuppressWarnings("unchecked") @Override//from w ww . ja va 2 s . co m public ListAndCount<Comment> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new FacebookModule()); jp.setCodec(mapper); if (jp.hasCurrentToken()) { JsonNode commentsNode = jp.readValueAs(JsonNode.class); JsonNode dataNode = commentsNode.get("data"); List<Comment> commentsList = dataNode != null ? (List<Comment>) mapper.reader(new TypeReference<List<Comment>>() { }).readValue(dataNode) : Collections.<Comment>emptyList(); JsonNode countNode = commentsNode.get("count"); int commentCount = countNode != null ? countNode.intValue() : 0; return new ListAndCount<Comment>(commentsList, commentCount); } return null; }