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