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