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 static java.util.Collections.unmodifiableList;
026import java.util.ArrayList;
027import java.util.Date;
028import java.util.List;
029import com.restfb.Facebook;
030import com.restfb.JsonMapper;
031import com.restfb.JsonMapper.JsonMappingCompleted;
032import com.restfb.annotation.GraphAPI;
033import com.restfb.exception.FacebookJsonMappingException;
034import com.restfb.json.JsonObject;
035
036/**
037 * Represents the <a href="https://developers.facebook.com/docs/graph-api/reference/photo/">Photo Graph API type</a>.
038 * 
039 * @author <a href="http://restfb.com">Mark Allen</a>
040 * @since 1.5
041 */
042public class Photo extends NamedFacebookType {
043  /**
044   * An object containing the name and ID of the user who posted the photo.
045   */
046  @Facebook
047  private CategorizedFacebookType from;
048  /**
049   * The album-sized view of the photo.
050   */
051  @Facebook
052  private String picture;
053  /**
054   * ID of the page story this corresponds to.
055   *
056   * May not be on all photos. Applies only to published photos
057   */
058  @Facebook("page_story_id")
059  private String pageStoryId;
060  /**
061   * The reactions for this photo.
062   */
063  @Facebook
064  private Reactions reactions;
065  /**
066   * The full-sized source of the photo.
067   *
068   * @deprecated Use <code>images</code> field instead
069   */
070  @Facebook
071  @Deprecated
072  private String source;
073  /**
074   * The height of the photo, in pixels.
075   */
076  @Facebook
077  private Integer height;
078  /**
079   * The width of the photo, in pixels.
080   */
081  @Facebook
082  private Integer width;
083  /**
084   * A link to the photo on Facebook.
085   */
086  @Facebook
087  private String link;
088  /**
089   * The icon-sized source of the photo.
090   */
091  @Facebook
092  private String icon;
093  /**
094   * The album this photo is in
095   */
096  @Facebook
097  private Album album;
098  /**
099   * A boolean indicating if the viewer can delete the photo
100   */
101  @Facebook("can_delete")
102  private Boolean canDelete;
103  /**
104   * A boolean indicating if the viewer can tag the photo
105   */
106  @Facebook("can_tag")
107  private Boolean canTag;
108  /**
109   * The position of this photo in the album.
110   *
111   * @since 1.6.5
112   * @deprecated Facebook will start returning 0 for this field starting on October 3, 2012.
113   */
114  @Deprecated
115  @Facebook
116  private Integer position;
117  /**
118   * If this object has a place, the event associated with the place
119   */
120  @Facebook
121  @GraphAPI(since = "2.3")
122  private Event event;
123  /**
124   * The last time the photo or its caption was updated.
125   */
126  @Facebook("updated_time")
127  private Date updatedTime;
128  /**
129   * The time the photo was initially published.
130   */
131  @Facebook("created_time")
132  private Date createdTime;
133  /**
134   * All of the comments on this photo.
135   *
136   * @since 1.6.5
137   */
138  @Facebook
139  private Comments comments;
140  @Facebook
141  private List<Tag> tags = new ArrayList<>();
142  @Facebook
143  private Likes likes;
144  @Facebook
145  private List<Image> images = new ArrayList<>();
146  @Facebook("name_tags")
147  private transient String rawNameTags;
148  private List<EntityAtTextRange> nameTags = new ArrayList<>();
149  /**
150   * The location associated with this photo, if any.
151   *
152   * @since 1.6.10
153   */
154  @Facebook
155  private Place place;
156  /**
157   * Back dated time
158   *
159   * @since 1.6.15
160   */
161  @Facebook("backdated_time")
162  private Date backdatedTime;
163  /**
164   * String that represents the back dated time granularity
165   *
166   * @since 1.6.15
167   */
168  @Facebook("backdated_time_granularity")
169  private String backdatedTimeGranularity;
170  private static final long serialVersionUID = 1L;
171
172
173  /**
174   * Represents the <a href="http://developers.facebook.com/docs/reference/api/photo">Tag Graph API type</a>.
175   * 
176   * @author <a href="http://restfb.com">Mark Allen</a>
177   * @since 1.5
178   */
179  public static class Tag extends NamedFacebookType {
180    /**
181     * X coordinate (as a percentage of distance from left vs. width).
182     */
183    @Facebook
184    private Double x;
185    /**
186     * Y coordinate (as a percentage of distance from top vs. height).
187     */
188    @Facebook
189    private Double y;
190    /**
191     * Date this tag was created.
192     */
193    @Facebook("created_time")
194    private Date createdTime;
195    private static final long serialVersionUID = 1L;
196
197    /**
198     * X coordinate (as a percentage of distance from left vs. width).
199     * 
200     * @return X coordinate (as a percentage of distance from left vs. width).
201     */
202    @java.lang.SuppressWarnings("all")
203    public Double getX() {
204      return this.x;
205    }
206
207    /**
208     * X coordinate (as a percentage of distance from left vs. width).
209     */
210    @java.lang.SuppressWarnings("all")
211    public void setX(final Double x) {
212      this.x = x;
213    }
214
215    /**
216     * Y coordinate (as a percentage of distance from top vs. height).
217     * 
218     * @return Y coordinate (as a percentage of distance from top vs. height).
219     */
220    @java.lang.SuppressWarnings("all")
221    public Double getY() {
222      return this.y;
223    }
224
225    /**
226     * Y coordinate (as a percentage of distance from top vs. height).
227     */
228    @java.lang.SuppressWarnings("all")
229    public void setY(final Double y) {
230      this.y = y;
231    }
232
233    /**
234     * Date this tag was created.
235     * 
236     * @return Date this tag was created.
237     */
238    @java.lang.SuppressWarnings("all")
239    public Date getCreatedTime() {
240      return this.createdTime;
241    }
242
243    /**
244     * Date this tag was created.
245     */
246    @java.lang.SuppressWarnings("all")
247    public void setCreatedTime(final Date createdTime) {
248      this.createdTime = createdTime;
249    }
250  }
251
252
253  /**
254   * Represents the <a href="http://developers.facebook.com/docs/reference/api/photo">Image Graph API type</a>.
255   * 
256   * @author <a href="http://restfb.com">Mark Allen</a>
257   * @since 1.6.5
258   */
259  public static class Image extends AbstractFacebookType {
260    /**
261     * The height of the image in pixels.
262     */
263    @Facebook
264    private Integer height;
265    /**
266     * The width of the image in pixels.
267     */
268    @Facebook
269    private Integer width;
270    /**
271     * The source URL of the image.
272     */
273    @Facebook
274    private String source;
275    private static final long serialVersionUID = 1L;
276
277    /**
278     * The height of the image in pixels.
279     * 
280     * @return The height of the image in pixels.
281     */
282    @java.lang.SuppressWarnings("all")
283    public Integer getHeight() {
284      return this.height;
285    }
286
287    /**
288     * The height of the image in pixels.
289     */
290    @java.lang.SuppressWarnings("all")
291    public void setHeight(final Integer height) {
292      this.height = height;
293    }
294
295    /**
296     * The width of the image in pixels.
297     * 
298     * @return The width of the image in pixels.
299     */
300    @java.lang.SuppressWarnings("all")
301    public Integer getWidth() {
302      return this.width;
303    }
304
305    /**
306     * The width of the image in pixels.
307     */
308    @java.lang.SuppressWarnings("all")
309    public void setWidth(final Integer width) {
310      this.width = width;
311    }
312
313    /**
314     * The source URL of the image.
315     * 
316     * @return The source URL of the image.
317     */
318    @java.lang.SuppressWarnings("all")
319    public String getSource() {
320      return this.source;
321    }
322
323    /**
324     * The source URL of the image.
325     */
326    @java.lang.SuppressWarnings("all")
327    public void setSource(final String source) {
328      this.source = source;
329    }
330  }
331
332  /**
333   * An array containing the users and their positions in this photo. The x and y coordinates are percentages from the
334   * left and top edges of the photo, respectively.
335   * 
336   * @return An array containing the users and their positions in this photo. The x and y coordinates are percentages
337   *         from the left and top edges of the photo, respectively.
338   */
339  public List<Tag> getTags() {
340    return unmodifiableList(tags);
341  }
342
343  public boolean addTag(Tag tag) {
344    return tags.add(tag);
345  }
346
347  public boolean removeTag(Tag tag) {
348    return tags.remove(tag);
349  }
350
351  public List<EntityAtTextRange> getNameTags() {
352    return unmodifiableList(nameTags);
353  }
354
355  public boolean addNameTag(EntityAtTextRange nameTag) {
356    return nameTags.add(nameTag);
357  }
358
359  public boolean removeNameTag(EntityAtTextRange nameTag) {
360    return nameTags.remove(nameTag);
361  }
362
363  /**
364   * The 4 different stored representations of the photo.
365   * 
366   * @return The 4 different stored representations of the photo.
367   * @since 1.6.5
368   */
369  public List<Image> getImages() {
370    return unmodifiableList(images);
371  }
372
373  public boolean addImage(Image image) {
374    return images.add(image);
375  }
376
377  public boolean removeImage(Image image) {
378    return images.remove(image);
379  }
380
381  /**
382   * Post-JSON-mapping operation that populates the {@code messageTags} field "by hand".
383   *
384   * @param jsonMapper
385   *          The {@code JsonMapper} that was used to map to this type.
386   */
387  @JsonMappingCompleted
388  protected void jsonMappingCompleted(JsonMapper jsonMapper) {
389    if (rawNameTags == null) {
390      return;
391    }
392    try {
393      nameTags = jsonMapper.toJavaList(rawNameTags, EntityAtTextRange.class);
394      return;
395    } catch (FacebookJsonMappingException je) {
396    }
397    // message tags not in Graph API 2.5 format, ignore this exception and try another way
398    try {
399      JsonObject rawMessageTagsObject = jsonMapper.toJavaObject(rawNameTags, JsonObject.class);
400      for (String key : rawMessageTagsObject.names()) {
401        String tagArrayString = rawMessageTagsObject.get(key).toString();
402        nameTags.addAll(jsonMapper.toJavaList(tagArrayString, EntityAtTextRange.class));
403      }
404    } catch (FacebookJsonMappingException je) {
405    }
406    // cannot parse message tags, but don't break the flow here
407  }
408
409  /**
410   * An object containing the name and ID of the user who posted the photo.
411   * 
412   * @return An object containing the name and ID of the user who posted the photo.
413   */
414  @java.lang.SuppressWarnings("all")
415  public CategorizedFacebookType getFrom() {
416    return this.from;
417  }
418
419  /**
420   * An object containing the name and ID of the user who posted the photo.
421   */
422  @java.lang.SuppressWarnings("all")
423  public void setFrom(final CategorizedFacebookType from) {
424    this.from = from;
425  }
426
427  /**
428   * The album-sized view of the photo.
429   * 
430   * @return The album-sized view of the photo.
431   */
432  @java.lang.SuppressWarnings("all")
433  public String getPicture() {
434    return this.picture;
435  }
436
437  /**
438   * The album-sized view of the photo.
439   */
440  @java.lang.SuppressWarnings("all")
441  public void setPicture(final String picture) {
442    this.picture = picture;
443  }
444
445  /**
446   * ID of the page story this corresponds to.
447   *
448   * May not be on all photos. Applies only to published photos
449   *
450   * @return ID of the page story this corresponds to.
451   */
452  @java.lang.SuppressWarnings("all")
453  public String getPageStoryId() {
454    return this.pageStoryId;
455  }
456
457  /**
458   * ID of the page story this corresponds to.
459   *
460   * May not be on all photos. Applies only to published photos
461   */
462  @java.lang.SuppressWarnings("all")
463  public void setPageStoryId(final String pageStoryId) {
464    this.pageStoryId = pageStoryId;
465  }
466
467  /**
468   * The reactions for this photo.
469   *
470   * @return The reactions for this photo.
471   */
472  @java.lang.SuppressWarnings("all")
473  public Reactions getReactions() {
474    return this.reactions;
475  }
476
477  /**
478   * The reactions for this photo.
479   */
480  @java.lang.SuppressWarnings("all")
481  public void setReactions(final Reactions reactions) {
482    this.reactions = reactions;
483  }
484
485  /**
486   * The full-sized source of the photo.
487   * 
488   * @return The full-sized source of the photo.
489   * @deprecated Use <code>images</code> field instead
490   */
491  @java.lang.Deprecated
492  @java.lang.SuppressWarnings("all")
493  public String getSource() {
494    return this.source;
495  }
496
497  /**
498   * The full-sized source of the photo.
499   *
500   * @deprecated Use <code>images</code> field instead
501   */
502  @java.lang.Deprecated
503  @java.lang.SuppressWarnings("all")
504  public void setSource(final String source) {
505    this.source = source;
506  }
507
508  /**
509   * The height of the photo, in pixels.
510   * 
511   * @return The height of the photo, in pixels.
512   */
513  @java.lang.SuppressWarnings("all")
514  public Integer getHeight() {
515    return this.height;
516  }
517
518  /**
519   * The height of the photo, in pixels.
520   */
521  @java.lang.SuppressWarnings("all")
522  public void setHeight(final Integer height) {
523    this.height = height;
524  }
525
526  /**
527   * The width of the photo, in pixels.
528   * 
529   * @return The width of the photo, in pixels.
530   */
531  @java.lang.SuppressWarnings("all")
532  public Integer getWidth() {
533    return this.width;
534  }
535
536  /**
537   * The width of the photo, in pixels.
538   */
539  @java.lang.SuppressWarnings("all")
540  public void setWidth(final Integer width) {
541    this.width = width;
542  }
543
544  /**
545   * A link to the photo on Facebook.
546   * 
547   * @return A link to the photo on Facebook.
548   */
549  @java.lang.SuppressWarnings("all")
550  public String getLink() {
551    return this.link;
552  }
553
554  /**
555   * A link to the photo on Facebook.
556   */
557  @java.lang.SuppressWarnings("all")
558  public void setLink(final String link) {
559    this.link = link;
560  }
561
562  /**
563   * The icon-sized source of the photo.
564   * 
565   * @return The icon-sized source of the photo.
566   */
567  @java.lang.SuppressWarnings("all")
568  public String getIcon() {
569    return this.icon;
570  }
571
572  /**
573   * The icon-sized source of the photo.
574   */
575  @java.lang.SuppressWarnings("all")
576  public void setIcon(final String icon) {
577    this.icon = icon;
578  }
579
580  /**
581   * The album this photo is in
582   *
583   * @return The album this photo is in
584   */
585  @java.lang.SuppressWarnings("all")
586  public Album getAlbum() {
587    return this.album;
588  }
589
590  /**
591   * The album this photo is in
592   */
593  @java.lang.SuppressWarnings("all")
594  public void setAlbum(final Album album) {
595    this.album = album;
596  }
597
598  /**
599   * A boolean indicating if the viewer can delete the photo
600   *
601   * @return A boolean indicating if the viewer can delete the photo
602   */
603  @java.lang.SuppressWarnings("all")
604  public Boolean getCanDelete() {
605    return this.canDelete;
606  }
607
608  /**
609   * A boolean indicating if the viewer can delete the photo
610   */
611  @java.lang.SuppressWarnings("all")
612  public void setCanDelete(final Boolean canDelete) {
613    this.canDelete = canDelete;
614  }
615
616  /**
617   * A boolean indicating if the viewer can tag the photo
618   *
619   * @return A boolean indicating if the viewer can tag the photo
620   */
621  @java.lang.SuppressWarnings("all")
622  public Boolean getCanTag() {
623    return this.canTag;
624  }
625
626  /**
627   * A boolean indicating if the viewer can tag the photo
628   */
629  @java.lang.SuppressWarnings("all")
630  public void setCanTag(final Boolean canTag) {
631    this.canTag = canTag;
632  }
633
634  /**
635   * The position of this photo in the album.
636   * 
637   * @return The position of this photo in the album.
638   * @since 1.6.5
639   * @deprecated Facebook will start returning 0 for this field starting on October 3, 2012.
640   */
641  @java.lang.Deprecated
642  @java.lang.SuppressWarnings("all")
643  public Integer getPosition() {
644    return this.position;
645  }
646
647  /**
648   * The position of this photo in the album.
649   *
650   * @since 1.6.5
651   * @deprecated Facebook will start returning 0 for this field starting on October 3, 2012.
652   */
653  @java.lang.Deprecated
654  @java.lang.SuppressWarnings("all")
655  public void setPosition(final Integer position) {
656    this.position = position;
657  }
658
659  /**
660   * If this object has a place, the event associated with the place
661   *
662   * @return If this object has a place, the event associated with the place
663   */
664  @GraphAPI(since = "2.3")
665  @java.lang.SuppressWarnings("all")
666  public Event getEvent() {
667    return this.event;
668  }
669
670  /**
671   * If this object has a place, the event associated with the place
672   */
673  @java.lang.SuppressWarnings("all")
674  public void setEvent(final Event event) {
675    this.event = event;
676  }
677
678  /**
679   * The last time the photo or its caption was updated.
680   * 
681   * @return The last time the photo or its caption was updated.
682   */
683  @java.lang.SuppressWarnings("all")
684  public Date getUpdatedTime() {
685    return this.updatedTime;
686  }
687
688  /**
689   * The last time the photo or its caption was updated.
690   */
691  @java.lang.SuppressWarnings("all")
692  public void setUpdatedTime(final Date updatedTime) {
693    this.updatedTime = updatedTime;
694  }
695
696  /**
697   * The time the photo was initially published.
698   * 
699   * @return The time the photo was initially published.
700   */
701  @java.lang.SuppressWarnings("all")
702  public Date getCreatedTime() {
703    return this.createdTime;
704  }
705
706  /**
707   * The time the photo was initially published.
708   */
709  @java.lang.SuppressWarnings("all")
710  public void setCreatedTime(final Date createdTime) {
711    this.createdTime = createdTime;
712  }
713
714  /**
715   * All of the comments on this photo.
716   *
717   * @return All of the comments on this photo.
718   * @since 1.6.5
719   */
720  @java.lang.SuppressWarnings("all")
721  public Comments getComments() {
722    return this.comments;
723  }
724
725  /**
726   * All of the comments on this photo.
727   *
728   * @since 1.6.5
729   */
730  @java.lang.SuppressWarnings("all")
731  public void setComments(final Comments comments) {
732    this.comments = comments;
733  }
734
735  @java.lang.SuppressWarnings("all")
736  public Likes getLikes() {
737    return this.likes;
738  }
739
740  @java.lang.SuppressWarnings("all")
741  public void setLikes(final Likes likes) {
742    this.likes = likes;
743  }
744
745  /**
746   * The location associated with this photo, if any.
747   * 
748   * @return The place this photo was taken.
749   * @since 1.6.10
750   */
751  @java.lang.SuppressWarnings("all")
752  public Place getPlace() {
753    return this.place;
754  }
755
756  /**
757   * The location associated with this photo, if any.
758   *
759   * @since 1.6.10
760   */
761  @java.lang.SuppressWarnings("all")
762  public void setPlace(final Place place) {
763    this.place = place;
764  }
765
766  /**
767   * Back dated time
768   * 
769   * @return the back dated time
770   * @since 1.6.15
771   */
772  @java.lang.SuppressWarnings("all")
773  public Date getBackdatedTime() {
774    return this.backdatedTime;
775  }
776
777  /**
778   * Back dated time
779   *
780   * @since 1.6.15
781   */
782  @java.lang.SuppressWarnings("all")
783  public void setBackdatedTime(final Date backdatedTime) {
784    this.backdatedTime = backdatedTime;
785  }
786
787  /**
788   * String that represents the back dated time granularity
789   * 
790   * @return the back dated time granularity
791   * @since 1.6.15
792   */
793  @java.lang.SuppressWarnings("all")
794  public String getBackdatedTimeGranularity() {
795    return this.backdatedTimeGranularity;
796  }
797
798  /**
799   * String that represents the back dated time granularity
800   *
801   * @since 1.6.15
802   */
803  @java.lang.SuppressWarnings("all")
804  public void setBackdatedTimeGranularity(final String backdatedTimeGranularity) {
805    this.backdatedTimeGranularity = backdatedTimeGranularity;
806  }
807}