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