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