001// Generated by delombok at Fri Oct 04 16:05:59 CEST 2024 002/* 003 * Copyright (c) 2010-2024 Mark Allen, Norbert Bartels. 004 * 005 * Permission is hereby granted, free of charge, to any person obtaining a copy 006 * of this software and associated documentation files (the "Software"), to deal 007 * in the Software without restriction, including without limitation the rights 008 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 009 * copies of the Software, and to permit persons to whom the Software is 010 * furnished to do so, subject to the following conditions: 011 * 012 * The above copyright notice and this permission notice shall be included in 013 * all copies or substantial portions of the Software. 014 * 015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 016 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 017 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 018 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 019 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 020 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 021 * THE SOFTWARE. 022 */ 023package com.restfb.types; 024 025import java.util.Date; 026import com.restfb.Facebook; 027import com.restfb.JsonMapper.JsonMappingCompleted; 028import com.restfb.json.Json; 029import com.restfb.json.JsonObject; 030import com.restfb.types.ads.AppLinks; 031 032/** 033 * Represents an external URL as it relates to the Facebook social graph - shares and comments from the URL on Facebook, 034 * and any Open Graph objects associated with the URL. 035 * 036 * Represents the <a href="https://developers.facebook.com/docs/graph-api/reference/url">URL Graph API type</a>. 037 * 038 * Facebook APi Version 2.1+ 039 * 040 * @since 1.7.0 041 */ 042public class Url extends FacebookType { 043 /** 044 * The Open Graph object that is canonically associated with this URL. 045 * 046 */ 047 @Facebook("og_object") 048 private OGObject ogObject; 049 /** 050 * AppLinks data associated with this URL. 051 */ 052 @Facebook("app_links") 053 private AppLinks appLinks; 054 @Facebook("share") 055 private String share; 056 @Facebook("engagement") 057 private String engagement; 058 /** 059 * The sum of comments on posts containing this URL on Facebook. 060 */ 061 private int commentCount; 062 /** 063 * The total shares of this URL all over Facebook. 064 * 065 * is set <code>0</code> if the share count is not present 066 */ 067 private int shareCount; 068 /** 069 * The sum of reactions across all posts containing the URL on Facebook. 070 */ 071 private int reactionCount; 072 /** 073 * The number shown in the comments plugin associated with the URL. This number does not include comments made on 074 * posts on Facebook. 075 */ 076 private int commentPluginCount; 077 078 @JsonMappingCompleted 079 void fillCounts() { 080 if (this.share != null) { 081 JsonObject shareObject = Json.parse(this.share).asObject(); 082 commentCount = shareObject.getInt("comment_count", commentCount); 083 shareCount = shareObject.getInt("share_count", shareCount); 084 } 085 if (this.engagement != null) { 086 JsonObject engagementObject = Json.parse(this.engagement).asObject(); 087 commentCount = engagementObject.getInt("comment_count", commentCount); 088 shareCount = engagementObject.getInt("share_count", shareCount); 089 reactionCount = engagementObject.getInt("reaction_count", reactionCount); 090 commentPluginCount = engagementObject.getInt("comment_plugin_count", commentPluginCount); 091 } 092 } 093 094 private static final long serialVersionUID = 1L; 095 096 097 /** 098 * The Open Graph object that is canonically associated with this URL. 099 */ 100 public static class OGObject extends FacebookType { 101 private static final long serialVersionUID = 1L; 102 /** 103 * The description of the object. 104 * 105 * -- GETTER -- 106 * @return The description of the object 107 */ 108 @Facebook 109 private String description; 110 /** 111 * The title of the object. 112 * 113 * -- GETTER -- 114 * @return The title of the object 115 */ 116 @Facebook 117 private String title; 118 /** 119 * The object type. 120 * 121 * -- GETTER -- 122 * @return The object type as String 123 */ 124 @Facebook 125 private String type; 126 /** 127 * This URL. 128 * 129 * -- GETTER -- 130 * @return This URL 131 */ 132 @Facebook 133 private String url; 134 /** 135 * When the object was last updated. 136 * 137 * -- GETTER -- 138 * @return date when the object was last updated. 139 */ 140 @Facebook("updated_time") 141 private Date updatedTime; 142 /** 143 * The image url 144 * 145 * -- GETTER -- 146 * @return image url 147 */ 148 @Facebook 149 private String image; 150 151 @java.lang.SuppressWarnings("all") 152 public String getDescription() { 153 return this.description; 154 } 155 156 @java.lang.SuppressWarnings("all") 157 public void setDescription(final String description) { 158 this.description = description; 159 } 160 161 @java.lang.SuppressWarnings("all") 162 public String getTitle() { 163 return this.title; 164 } 165 166 @java.lang.SuppressWarnings("all") 167 public void setTitle(final String title) { 168 this.title = title; 169 } 170 171 @java.lang.SuppressWarnings("all") 172 public String getType() { 173 return this.type; 174 } 175 176 @java.lang.SuppressWarnings("all") 177 public void setType(final String type) { 178 this.type = type; 179 } 180 181 @java.lang.SuppressWarnings("all") 182 public String getUrl() { 183 return this.url; 184 } 185 186 @java.lang.SuppressWarnings("all") 187 public void setUrl(final String url) { 188 this.url = url; 189 } 190 191 @java.lang.SuppressWarnings("all") 192 public Date getUpdatedTime() { 193 return this.updatedTime; 194 } 195 196 @java.lang.SuppressWarnings("all") 197 public void setUpdatedTime(final Date updatedTime) { 198 this.updatedTime = updatedTime; 199 } 200 201 @java.lang.SuppressWarnings("all") 202 public String getImage() { 203 return this.image; 204 } 205 206 @java.lang.SuppressWarnings("all") 207 public void setImage(final String image) { 208 this.image = image; 209 } 210 } 211 212 /** 213 * The Open Graph object that is canonically associated with this URL. 214 * 215 * @return The Open Graph object that is canonically associated with this URL 216 */ 217 @java.lang.SuppressWarnings("all") 218 public OGObject getOgObject() { 219 return this.ogObject; 220 } 221 222 /** 223 * The Open Graph object that is canonically associated with this URL. 224 * 225 */ 226 @java.lang.SuppressWarnings("all") 227 public void setOgObject(final OGObject ogObject) { 228 this.ogObject = ogObject; 229 } 230 231 /** 232 * @return AppLinks data associated with this URL. 233 */ 234 @java.lang.SuppressWarnings("all") 235 public AppLinks getAppLinks() { 236 return this.appLinks; 237 } 238 239 /** 240 * AppLinks data associated with this URL. 241 */ 242 @java.lang.SuppressWarnings("all") 243 public void setAppLinks(final AppLinks appLinks) { 244 this.appLinks = appLinks; 245 } 246 247 /** 248 * @return The sum of comments on posts containing this URL on Facebook. 249 */ 250 @java.lang.SuppressWarnings("all") 251 public int getCommentCount() { 252 return this.commentCount; 253 } 254 255 /** 256 * The sum of comments on posts containing this URL on Facebook. 257 */ 258 @java.lang.SuppressWarnings("all") 259 public void setCommentCount(final int commentCount) { 260 this.commentCount = commentCount; 261 } 262 263 /** 264 * @return The total shares of this URL all over Facebook. 265 */ 266 @java.lang.SuppressWarnings("all") 267 public int getShareCount() { 268 return this.shareCount; 269 } 270 271 /** 272 * The total shares of this URL all over Facebook. 273 * 274 * is set <code>0</code> if the share count is not present 275 */ 276 @java.lang.SuppressWarnings("all") 277 public void setShareCount(final int shareCount) { 278 this.shareCount = shareCount; 279 } 280 281 /** 282 * @return The sum of reactions across all posts containing the URL on Facebook. 283 */ 284 @java.lang.SuppressWarnings("all") 285 public int getReactionCount() { 286 return this.reactionCount; 287 } 288 289 /** 290 * The sum of reactions across all posts containing the URL on Facebook. 291 */ 292 @java.lang.SuppressWarnings("all") 293 public void setReactionCount(final int reactionCount) { 294 this.reactionCount = reactionCount; 295 } 296 297 /** 298 * @return The number shown in the comments plugin associated with the URL. This number does not include comments made 299 * on posts on Facebook. 300 */ 301 @java.lang.SuppressWarnings("all") 302 public int getCommentPluginCount() { 303 return this.commentPluginCount; 304 } 305 306 /** 307 * The number shown in the comments plugin associated with the URL. This number does not include comments made on 308 * posts on Facebook. 309 */ 310 @java.lang.SuppressWarnings("all") 311 public void setCommentPluginCount(final int commentPluginCount) { 312 this.commentPluginCount = commentPluginCount; 313 } 314}