001// Generated by delombok at Fri Oct 11 21:56:29 CEST 2019
002/**
003 * Copyright (c) 2010-2019 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  @Facebook("og_object")
047  private OGObject ogObject;
048  /**
049   * AppLinks data associated with this URL.
050   */
051  @Facebook("app_links")
052  private AppLinks appLinks;
053  @Facebook("share")
054  private String share;
055  @Facebook("engagement")
056  private String engagement;
057  /**
058   * The sum of comments on posts containing this URL on Facebook.
059   */
060  private int commentCount;
061  /**
062   * The total shares of this URL all over Facebook.
063   * 
064   * is set <code>0</code> if the share count is not present
065   */
066  private int shareCount;
067  /**
068   * The sum of reactions across all posts containing the URL on Facebook.
069   */
070  private int reactionCount;
071  /**
072   * The number shown in the comments plugin associated with the URL. This number does not include comments made on
073   * posts on Facebook.
074   */
075  private int commentPluginCount;
076
077  @JsonMappingCompleted
078  void fillCounts() {
079    if (this.share != null) {
080      JsonObject shareObject = Json.parse(this.share).asObject();
081      commentCount = shareObject.getInt("comment_count", commentCount);
082      shareCount = shareObject.getInt("share_count", shareCount);
083    }
084    if (this.engagement != null) {
085      JsonObject engagementObject = Json.parse(this.engagement).asObject();
086      commentCount = engagementObject.getInt("comment_count", commentCount);
087      shareCount = engagementObject.getInt("share_count", shareCount);
088      reactionCount = engagementObject.getInt("reaction_count", reactionCount);
089      commentPluginCount = engagementObject.getInt("comment_plugin_count", commentPluginCount);
090    }
091  }
092
093  private static final long serialVersionUID = 1L;
094
095
096  /**
097   * The Open Graph object that is canonically associated with this URL.
098   */
099  public static class OGObject extends FacebookType {
100    private static final long serialVersionUID = 1L;
101    /**
102     * The description of the object.
103     *
104     * -- GETTER --
105     * @return The description of the object
106     */
107    @Facebook
108    private String description;
109    /**
110     * The title of the object.
111     *
112     * -- GETTER --
113     * @return The title of the object
114     */
115    @Facebook
116    private String title;
117    /**
118     * The object type.
119     *
120     * -- GETTER --
121     * @return The object type as String
122     */
123    @Facebook
124    private String type;
125    /**
126     * This URL.
127     *
128     * -- GETTER --
129     * @return This URL
130     */
131    @Facebook
132    private String url;
133    /**
134     * When the object was last updated.
135     *
136     * -- GETTER --
137     * @return date when the object was last updated.
138     */
139    @Facebook("updated_time")
140    private Date updatedTime;
141    /**
142     * The image url
143     *
144     * -- GETTER --
145     * @return image url
146     */
147    @Facebook
148    private String image;
149
150    @java.lang.SuppressWarnings("all")
151    public String getDescription() {
152      return this.description;
153    }
154
155    @java.lang.SuppressWarnings("all")
156    public void setDescription(final String description) {
157      this.description = description;
158    }
159
160    @java.lang.SuppressWarnings("all")
161    public String getTitle() {
162      return this.title;
163    }
164
165    @java.lang.SuppressWarnings("all")
166    public void setTitle(final String title) {
167      this.title = title;
168    }
169
170    @java.lang.SuppressWarnings("all")
171    public String getType() {
172      return this.type;
173    }
174
175    @java.lang.SuppressWarnings("all")
176    public void setType(final String type) {
177      this.type = type;
178    }
179
180    @java.lang.SuppressWarnings("all")
181    public String getUrl() {
182      return this.url;
183    }
184
185    @java.lang.SuppressWarnings("all")
186    public void setUrl(final String url) {
187      this.url = url;
188    }
189
190    @java.lang.SuppressWarnings("all")
191    public Date getUpdatedTime() {
192      return this.updatedTime;
193    }
194
195    @java.lang.SuppressWarnings("all")
196    public void setUpdatedTime(final Date updatedTime) {
197      this.updatedTime = updatedTime;
198    }
199
200    @java.lang.SuppressWarnings("all")
201    public String getImage() {
202      return this.image;
203    }
204
205    @java.lang.SuppressWarnings("all")
206    public void setImage(final String image) {
207      this.image = image;
208    }
209  }
210
211  /**
212   * The Open Graph object that is canonically associated with this URL.
213   * 
214   * @return The Open Graph object that is canonically associated with this URL
215   */
216  @java.lang.SuppressWarnings("all")
217  public OGObject getOgObject() {
218    return this.ogObject;
219  }
220
221  /**
222   * The Open Graph object that is canonically associated with this URL.
223   */
224  @java.lang.SuppressWarnings("all")
225  public void setOgObject(final OGObject ogObject) {
226    this.ogObject = ogObject;
227  }
228
229  /**
230   *
231   * @return AppLinks data associated with this URL.
232   */
233  @java.lang.SuppressWarnings("all")
234  public AppLinks getAppLinks() {
235    return this.appLinks;
236  }
237
238  /**
239   * AppLinks data associated with this URL.
240   */
241  @java.lang.SuppressWarnings("all")
242  public void setAppLinks(final AppLinks appLinks) {
243    this.appLinks = appLinks;
244  }
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   *
265   * @return The total shares of this URL all over Facebook.
266   */
267  @java.lang.SuppressWarnings("all")
268  public int getShareCount() {
269    return this.shareCount;
270  }
271
272  /**
273   * The total shares of this URL all over Facebook.
274   * 
275   * is set <code>0</code> if the share count is not present
276   */
277  @java.lang.SuppressWarnings("all")
278  public void setShareCount(final int shareCount) {
279    this.shareCount = shareCount;
280  }
281
282  /**
283   *
284   * @return The sum of reactions across all posts containing the URL on Facebook.
285   */
286  @java.lang.SuppressWarnings("all")
287  public int getReactionCount() {
288    return this.reactionCount;
289  }
290
291  /**
292   * The sum of reactions across all posts containing the URL on Facebook.
293   */
294  @java.lang.SuppressWarnings("all")
295  public void setReactionCount(final int reactionCount) {
296    this.reactionCount = reactionCount;
297  }
298
299  /**
300   *
301   * @return The number shown in the comments plugin associated with the URL. This number does not include comments made
302   *         on posts on Facebook.
303   */
304  @java.lang.SuppressWarnings("all")
305  public int getCommentPluginCount() {
306    return this.commentPluginCount;
307  }
308
309  /**
310   * The number shown in the comments plugin associated with the URL. This number does not include comments made on
311   * posts on Facebook.
312   */
313  @java.lang.SuppressWarnings("all")
314  public void setCommentPluginCount(final int commentPluginCount) {
315    this.commentPluginCount = commentPluginCount;
316  }
317}