@JsonMapper.JsonMappingCompleted private void convertAppRoles() { if (rawAppRoles != null) { AppRoles appRoles = new AppRoles(); for (String appId : rawAppRoles.names()) { List<JsonValue> rawRoles = rawAppRoles.get(appId).asArray().values(); List<String> roles = new ArrayList<>(); for (JsonValue rawValue : rawRoles) { roles.add(rawValue.asString()); } appRoles.addRoles(appId, roles); } this.appRoles = appRoles; } }
/** * Post-JSON-mapping operation that populates the {@code messageTags} field "by hand". * * @param jsonMapper * The {@code JsonMapper} that was used to map to this type. */ @JsonMappingCompleted protected void jsonMappingCompleted(JsonMapper jsonMapper) { if (rawMessageTags == null) { return; } try { messageTags = jsonMapper.toJavaList(rawMessageTags, MessageTag.class); return; } catch (FacebookJsonMappingException je) { } // message tags not in Graph API 2.5 format, ignore this exception and try another way try { JsonObject rawMessageTagsObject = jsonMapper.toJavaObject(rawMessageTags, JsonObject.class); for (String key : rawMessageTagsObject.names()) { String tagArrayString = rawMessageTagsObject.get(key).toString(); messageTags.addAll(jsonMapper.toJavaList(tagArrayString, MessageTag.class)); } } catch (FacebookJsonMappingException je) { } // cannot parse message tags, but don't break the flow here }
/** * Post-JSON-mapping operation that populates the {@code messageTags} field "by hand". * * @param jsonMapper * The {@code JsonMapper} that was used to map to this type. */ @JsonMappingCompleted protected void jsonMappingCompleted(JsonMapper jsonMapper) { if (rawNameTags == null) { return; } try { nameTags = jsonMapper.toJavaList(rawNameTags, EntityAtTextRange.class); return; } catch (FacebookJsonMappingException je) { } // message tags not in Graph API 2.5 format, ignore this exception and try another way try { JsonObject rawMessageTagsObject = jsonMapper.toJavaObject(rawNameTags, JsonObject.class); for (String key : rawMessageTagsObject.names()) { String tagArrayString = rawMessageTagsObject.get(key).toString(); nameTags.addAll(jsonMapper.toJavaList(tagArrayString, EntityAtTextRange.class)); } } catch (FacebookJsonMappingException je) { } // cannot parse message tags, but don't break the flow here }
/** * Post-JSON-mapping operation that populates the {@code messageTags} field "by hand". * <p> * This is a temporary hack until we have formal public support for it/improved {@code JsonMapper} capabilities so it * can handle arbitrary Map types. * * @param jsonMapper * The {@code JsonMapper} that was used to map to this type. * @since 1.6.11 */ @JsonMappingCompleted protected void jsonMappingCompleted(JsonMapper jsonMapper) { if (rawMessageTags != null) { messageTags = createTags(rawMessageTags, jsonMapper); } if (rawStoryTags != null) { storyTags = createTags(rawStoryTags, jsonMapper); } }
@JsonMappingCompleted protected void convertLabels(JsonMapper jsonMapper) { JsonObject rawLabels = null; if (this.rawLabels != null) { JsonValue jsonValue = Json.parse(this.rawLabels); if (jsonValue.isObject()) { rawLabels = jsonValue.asObject(); } } if (rawLabels != null && rawLabels.isObject()) { String innerLabelsString = rawLabels.get("data").toString(); labels = jsonMapper.toJavaList(innerLabelsString, PageLabel.class); } }
@JsonMappingCompleted void fillCounts() { if (this.share != null) { JsonObject shareObject = Json.parse(this.share).asObject(); commentCount = shareObject.getInt("comment_count", commentCount); shareCount = shareObject.getInt("share_count", shareCount); } if (this.engagement != null) { JsonObject engagementObject = Json.parse(this.engagement).asObject(); commentCount = engagementObject.getInt("comment_count", commentCount); shareCount = engagementObject.getInt("share_count", shareCount); reactionCount = engagementObject.getInt("reaction_count", reactionCount); commentPluginCount = engagementObject.getInt("comment_plugin_count", commentPluginCount); } }
@JsonMappingCompleted private void convertList(JsonMapper mapper) { if (rawRegionsString != null) { JsonValue jsonValue = Json.parse(rawRegionsString); if (jsonValue.isObject()) { JsonObject rawRegions = jsonValue.asObject(); for (String key : rawRegions.names()) { String region = rawRegions.get(key).toString(); regions.add(mapper.toJavaObject(region, KeyedType.class)); } } } }
@JsonMapper.JsonMappingCompleted public void convertVersion() { version = Version.getVersionFromString(versionAsString); }
@JsonMappingCompleted private void replaceId() { if (getId() == null && key != null) { setId(key); } if (key == null && getId() != null) { setKey(getId()); } }
@JsonMapper.JsonMappingCompleted private void convertCompatFields() { if (compatFields != null && fields == null) { fields = new ArrayList<>(); for (String field : compatFields) { fields.add(new SubscriptionField(field)); } } }
@JsonMappingCompleted void convertTime() { // Sometimes the date comes back in short form - if long form parsing // failed, try short instead Date dateEnd = toDateFromLongFormat(rawEndTime); endTime = dateEnd == null ? toDateFromShortFormat(rawEndTime) : dateEnd; Date dateStart = toDateFromLongFormat(rawStartTime); startTime = dateStart == null ? toDateFromShortFormat(rawStartTime) : dateStart; }
@JsonMapper.JsonMappingCompleted private void provideRecipient() { if (userRef != null) { userRefMessageRecipient = new UserRefMessageRecipient(userRef); } }
@JsonMappingCompleted protected void jsonMappingCompleted(JsonMapper jsonMapper) { MappingUtils mappingUtils = new MappingUtils(jsonMapper); picture = mappingUtils.convertPicture(rawPicture); }
@JsonMapper.JsonMappingCompleted private void fillFields() { JsonObject summaryObject = null; if (summary != null) { summaryObject = Json.parse(summary).asObject(); } fillViewerReaction(summaryObject); fillTotalCount(summaryObject); }
@JsonMappingCompleted private void fillFields() { JsonObject summaryObject = null; if (summary != null) { summaryObject = Json.parse(summary).asObject(); } fillTotalCount(summaryObject); fillOrder(summaryObject); fillCanComment(summaryObject); }
@JsonMapper.JsonMappingCompleted private void convertDate() { if (rawTimestamp != null) { timestamp = new Date(rawTimestamp); } }
@JsonMappingCompleted private void fillCoverPhoto() { if (coverPhoto == null && coverPhotoAsString != null) { coverPhoto = new Photo(); coverPhoto.setId(coverPhotoAsString); } }
@JsonMapper.JsonMappingCompleted private void convert() { thumb100x100 = createSpecFromString(thumb100x100String); thumb100x72 = createSpecFromString(thumb100x72String); thumb191x100 = createSpecFromString(thumb191x100String); thumb400x150 = createSpecFromString(thumb400x150String); thumb600x360 = createSpecFromString(thumb600x360String); }
@JsonMapper.JsonMappingCompleted private void selectPayload() { if (payload == null) { payload = new MessagingPayload(); payload.setFallback(fallbackPayload); } }
@JsonMappingCompleted protected void fillProfilePicture(JsonMapper jsonMapper) { MappingUtils mappingUtils = new MappingUtils(jsonMapper); picture = mappingUtils.convertPicture(rawPicture); }