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