001// Generated by delombok at Tue Sep 01 00:02:35 CEST 2020
002/*
003 * Copyright (c) 2010-2020 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.types.features.HasCreatedTime;
031import com.restfb.types.features.HasFrom;
032import com.restfb.types.features.HasMessage;
033
034/**
035 * Represents the <a href="http://developers.facebook.com/docs/reference/api/note">Note Graph API type</a>.
036 * 
037 * @author <a href="http://restfb.com">Mark Allen</a>
038 * @since 1.5
039 */
040public class Note extends FacebookType implements HasCreatedTime, HasFrom, HasMessage {
041  /**
042   * The ID of the user who posted the note.
043   */
044  @Facebook
045  private NamedFacebookType from;
046  /**
047   * The title of the note.
048   */
049  @Facebook
050  private String subject;
051  /**
052   * The note content, an HTML string.
053   */
054  @Facebook
055  private String message;
056  /**
057   * The note icon.
058   */
059  @Facebook
060  private String icon;
061  /**
062   * The time the note was initially published.
063   */
064  @Facebook("created_time")
065  private Date createdTime;
066  /**
067   * The time the note was last updated.
068   */
069  @Facebook("updated_time")
070  private Date updatedTime;
071  // It's possible for Facebook to return {"count":0} instead of a list of comments for whatever reason.
072  // So we have this throwaway field to hold that result. There is no need to expose this through the public API; it's
073  // here to let the JSON mapper work without erroring out.
074  @Facebook("comments")
075  private String commentsAsObject;
076  @Facebook("comments")
077  private List<Comment> comments = new ArrayList<>();
078  private static final long serialVersionUID = 1L;
079
080  /**
081   * Comments made on the note.
082   * 
083   * @return Comments made on the note.
084   * @since 1.6.10
085   */
086  public List<Comment> getComments() {
087    return unmodifiableList(comments);
088  }
089
090  public boolean addComment(Comment comment) {
091    return comments.add(comment);
092  }
093
094  public boolean removeComment(Comment comment) {
095    return comments.remove(comment);
096  }
097
098  /**
099   * The ID of the user who posted the note.
100   * 
101   * @return The ID of the user who posted the note.
102   */
103  @Override
104  @java.lang.SuppressWarnings("all")
105  public NamedFacebookType getFrom() {
106    return this.from;
107  }
108
109  /**
110   * The ID of the user who posted the note.
111   */
112  @java.lang.SuppressWarnings("all")
113  public void setFrom(final NamedFacebookType from) {
114    this.from = from;
115  }
116
117  /**
118   * The title of the note.
119   * 
120   * @return The title of the note.
121   */
122  @java.lang.SuppressWarnings("all")
123  public String getSubject() {
124    return this.subject;
125  }
126
127  /**
128   * The title of the note.
129   */
130  @java.lang.SuppressWarnings("all")
131  public void setSubject(final String subject) {
132    this.subject = subject;
133  }
134
135  /**
136   * The note content, an HTML string.
137   * 
138   * @return The note content, an HTML string.
139   */
140  @Override
141  @java.lang.SuppressWarnings("all")
142  public String getMessage() {
143    return this.message;
144  }
145
146  /**
147   * The note content, an HTML string.
148   */
149  @java.lang.SuppressWarnings("all")
150  public void setMessage(final String message) {
151    this.message = message;
152  }
153
154  /**
155   * The note icon.
156   * 
157   * @return The note icon.
158   */
159  @java.lang.SuppressWarnings("all")
160  public String getIcon() {
161    return this.icon;
162  }
163
164  /**
165   * The note icon.
166   */
167  @java.lang.SuppressWarnings("all")
168  public void setIcon(final String icon) {
169    this.icon = icon;
170  }
171
172  /**
173   * The time the note was initially published.
174   * 
175   * @return The time the note was initially published.
176   */
177  @Override
178  @java.lang.SuppressWarnings("all")
179  public Date getCreatedTime() {
180    return this.createdTime;
181  }
182
183  /**
184   * The time the note was initially published.
185   */
186  @java.lang.SuppressWarnings("all")
187  public void setCreatedTime(final Date createdTime) {
188    this.createdTime = createdTime;
189  }
190
191  /**
192   * The time the note was last updated.
193   * 
194   * @return The time the note was last updated.
195   */
196  @java.lang.SuppressWarnings("all")
197  public Date getUpdatedTime() {
198    return this.updatedTime;
199  }
200
201  /**
202   * The time the note was last updated.
203   */
204  @java.lang.SuppressWarnings("all")
205  public void setUpdatedTime(final Date updatedTime) {
206    this.updatedTime = updatedTime;
207  }
208
209  @java.lang.SuppressWarnings("all")
210  public String getCommentsAsObject() {
211    return this.commentsAsObject;
212  }
213
214  @java.lang.SuppressWarnings("all")
215  public void setCommentsAsObject(final String commentsAsObject) {
216    this.commentsAsObject = commentsAsObject;
217  }
218}