001// Generated by delombok at Sun Jul 07 22:01:31 CEST 2019
002/**
003 * Copyright (c) 2010-2019 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;
030
031/**
032 * Represents the <a href="http://developers.facebook.com/docs/reference/api/status">Status Message Graph API type</a>.
033 * 
034 * @author <a href="http://restfb.com">Mark Allen</a>
035 * @since 1.6
036 * @deprecated removed after Graph API 2.0
037 */
038@Deprecated
039public class StatusMessage extends NamedFacebookType {
040  /**
041   * The user who posted the message.
042   */
043  @Facebook
044  private NamedFacebookType from;
045  /**
046   * The status message content.
047   */
048  @Facebook
049  private String message;
050  /**
051   * The place where status message is attached.
052   *
053   * @since 1.6.15
054   */
055  @Facebook
056  private Place place;
057  /**
058   * The object type which is set to status.
059   */
060  @Facebook
061  private String type;
062  /**
063   * The time the message was published.
064   */
065  @Facebook("updated_time")
066  private Date updatedTime;
067  @Facebook
068  private List<NamedFacebookType> likes = new ArrayList<>();
069  /**
070   * Hack so JSON mapping won't fail when FB returns inconsistent JSON when there are 0 likes.
071   */
072  @Facebook("likes")
073  private EmptyLikes emptyLikes;
074  @Facebook
075  private List<Comment> comments = new ArrayList<>();
076  /**
077   * Hack so JSON mapping won't fail when FB returns inconsistent JSON when there are 0 comments.
078   */
079  @Facebook("comments")
080  private EmptyComments emptyComments;
081  private static final long serialVersionUID = 2L;
082
083
084  /**
085   * Sometimes Facebook will return <tt>"likes":{"count":0}</tt> instead of the connection-formatted likes object that's
086   * documented - this class handles that so JSON mapping won't fail.
087   * 
088   * @author <a href="http://restfb.com">Mark Allen</a>
089   * @since 1.6.8
090   */
091  private static class EmptyLikes extends AbstractFacebookType {
092    @Facebook
093    private Long count;
094    private static final long serialVersionUID = 1L;
095  }
096
097
098  /**
099   * Sometimes Facebook will return <tt>"comments":{"count":0}</tt> instead of the connection-formatted comments object
100   * that's documented - this class handles that so JSON mapping won't fail.
101   * 
102   * @author <a href="http://restfb.com">Mark Allen</a>
103   * @since 1.6.8
104   */
105  private static class EmptyComments extends AbstractFacebookType {
106    @Facebook
107    private Long count;
108    private static final long serialVersionUID = 1L;
109  }
110
111  /**
112   * The users that have liked this message.
113   * 
114   * @return The users that have liked this message.
115   */
116  public List<NamedFacebookType> getLikes() {
117    return unmodifiableList(likes);
118  }
119
120  public boolean addLike(NamedFacebookType like) {
121    return likes.add(like);
122  }
123
124  public boolean removeLike(NamedFacebookType like) {
125    return likes.remove(like);
126  }
127
128  /**
129   * All of the comments on this message.
130   * 
131   * @return All of the comments on this message.
132   */
133  public List<Comment> getComments() {
134    return unmodifiableList(comments);
135  }
136
137  public boolean addComment(Comment comment) {
138    return comments.add(comment);
139  }
140
141  public boolean removeComment(Comment comment) {
142    return comments.remove(comment);
143  }
144
145  /**
146   * The user who posted the message.
147   * 
148   * @return The user who posted the message.
149   */
150  @java.lang.SuppressWarnings("all")
151  public NamedFacebookType getFrom() {
152    return this.from;
153  }
154
155  /**
156   * The user who posted the message.
157   */
158  @java.lang.SuppressWarnings("all")
159  public void setFrom(final NamedFacebookType from) {
160    this.from = from;
161  }
162
163  /**
164   * The status message content.
165   * 
166   * @return The status message content.
167   */
168  @java.lang.SuppressWarnings("all")
169  public String getMessage() {
170    return this.message;
171  }
172
173  /**
174   * The status message content.
175   */
176  @java.lang.SuppressWarnings("all")
177  public void setMessage(final String message) {
178    this.message = message;
179  }
180
181  /**
182   * The place where status message is attached.
183   * 
184   * @return The place where the status message posted.
185   * @since 1.6.15
186   */
187  @java.lang.SuppressWarnings("all")
188  public Place getPlace() {
189    return this.place;
190  }
191
192  /**
193   * The place where status message is attached.
194   *
195   * @since 1.6.15
196   */
197  @java.lang.SuppressWarnings("all")
198  public void setPlace(final Place place) {
199    this.place = place;
200  }
201
202  /**
203   * The object type which is set to status.
204   * 
205   * @return The object type which is set to status.
206   */
207  @java.lang.SuppressWarnings("all")
208  public String getType() {
209    return this.type;
210  }
211
212  /**
213   * The object type which is set to status.
214   */
215  @java.lang.SuppressWarnings("all")
216  public void setType(final String type) {
217    this.type = type;
218  }
219
220  /**
221   * The time the message was published.
222   * 
223   * @return The time the message was published.
224   */
225  @java.lang.SuppressWarnings("all")
226  public Date getUpdatedTime() {
227    return this.updatedTime;
228  }
229
230  /**
231   * The time the message was published.
232   */
233  @java.lang.SuppressWarnings("all")
234  public void setUpdatedTime(final Date updatedTime) {
235    this.updatedTime = updatedTime;
236  }
237}