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