001// Generated by delombok at Thu Aug 13 13:56:44 UTC 2026
002/*
003 * Copyright (c) 2010-2026 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 java.util.Date;
026import com.restfb.Facebook;
027import com.restfb.JsonMapper;
028import com.restfb.JsonMapper.JsonMappingCompleted;
029import com.restfb.json.Json;
030import com.restfb.json.JsonObject;
031import com.restfb.types.features.HasComments;
032import com.restfb.types.features.HasFrom;
033import com.restfb.types.features.HasMessage;
034
035/**
036 * Represents the <a href="https://developers.facebook.com/docs/graph-api/reference/v1.0/page/ratings">Cover Graph API
037 * type</a>.
038 *
039 * @author Anand Hemmige
040 * @author Venil Noronha
041 * @since 1.6.16
042 */
043public class PageRating extends FacebookType implements HasComments, HasFrom, HasMessage {
044  private static final long serialVersionUID = 1L;
045  /**
046   * Time the rating took place
047   */
048  @Facebook("start_time")
049  private Date startTime;
050  /**
051   * Time the rating took place
052   */
053  @Facebook("publish_time")
054  private Date publishTime;
055  /**
056   * Person who rated the page
057   */
058  @Facebook
059  private NamedFacebookType from;
060  @Facebook
061  private String message;
062  @Facebook
063  private Application application;
064  @Facebook("no_feed_story")
065  private Boolean noFeedStory;
066  @Facebook
067  private Comments comments;
068  @Facebook
069  private Likes likes;
070  @Facebook
071  private String data;
072  private Double ratingValue;
073  private Long ratingScale;
074  private String reviewText;
075  private Boolean isDraft;
076  private String language;
077  private Place place;
078  private RecommendationType recommendationType;
079
080  public boolean isRecommendation() {
081    return ratingValue == null;
082  }
083
084  @JsonMappingCompleted
085  void fillAdditionalValues(JsonMapper mapper) {
086    if (this.data != null) {
087      JsonObject dataObject = Json.parse(this.data).asObject();
088      if (dataObject.get("rating") != null) {
089        JsonObject rating = dataObject.get("rating").asObject();
090        if (rating != null) {
091          ratingValue = rating.get("value").asDouble();
092          ratingScale = rating.get("scale").asLong();
093        }
094      }
095      if (dataObject.get("language") != null) {
096        language = dataObject.get("language").asString();
097      }
098      if (dataObject.get("is_draft") != null) {
099        isDraft = dataObject.get("is_draft").asBoolean();
100      }
101      if (dataObject.get("review_text") != null) {
102        reviewText = dataObject.get("review_text").asString();
103      }
104      if (dataObject.get("generic_place") != null) {
105        place = mapper.toJavaObject(dataObject.get("generic_place").toString(), Place.class);
106      } else if (dataObject.get("seller") != null) {
107        place = mapper.toJavaObject(dataObject.get("seller").toString(), Place.class);
108      }
109      if (dataObject.get("recommendation_type") != null) {
110        try {
111          String typeString = dataObject.get("recommendation_type").asString();
112          recommendationType = RecommendationType.valueOf(typeString.toUpperCase());
113        } catch (IllegalArgumentException iae) {
114        }
115      }
116    }
117    // no enum value found ignore this
118  }
119
120  /**
121   * Time the rating took place
122   *
123   * @return Time the rating took place
124   */
125  @java.lang.SuppressWarnings("all")
126  @lombok.Generated
127  public Date getStartTime() {
128    return this.startTime;
129  }
130
131  /**
132   * Time the rating took place
133   */
134  @java.lang.SuppressWarnings("all")
135  @lombok.Generated
136  public void setStartTime(final Date startTime) {
137    this.startTime = startTime;
138  }
139
140  /**
141   * Time the rating took place
142   *
143   * @return Time the rating took place
144   */
145  @java.lang.SuppressWarnings("all")
146  @lombok.Generated
147  public Date getPublishTime() {
148    return this.publishTime;
149  }
150
151  /**
152   * Time the rating took place
153   */
154  @java.lang.SuppressWarnings("all")
155  @lombok.Generated
156  public void setPublishTime(final Date publishTime) {
157    this.publishTime = publishTime;
158  }
159
160  /**
161   * Person who rated the page
162   *
163   * @return Person who rated the page
164   */
165  @Override
166  @java.lang.SuppressWarnings("all")
167  @lombok.Generated
168  public NamedFacebookType getFrom() {
169    return this.from;
170  }
171
172  /**
173   * Person who rated the page
174   */
175  @java.lang.SuppressWarnings("all")
176  @lombok.Generated
177  public void setFrom(final NamedFacebookType from) {
178    this.from = from;
179  }
180
181  @Override
182  @java.lang.SuppressWarnings("all")
183  @lombok.Generated
184  public String getMessage() {
185    return this.message;
186  }
187
188  @java.lang.SuppressWarnings("all")
189  @lombok.Generated
190  public void setMessage(final String message) {
191    this.message = message;
192  }
193
194  @java.lang.SuppressWarnings("all")
195  @lombok.Generated
196  public Application getApplication() {
197    return this.application;
198  }
199
200  @java.lang.SuppressWarnings("all")
201  @lombok.Generated
202  public void setApplication(final Application application) {
203    this.application = application;
204  }
205
206  @java.lang.SuppressWarnings("all")
207  @lombok.Generated
208  public Boolean getNoFeedStory() {
209    return this.noFeedStory;
210  }
211
212  @java.lang.SuppressWarnings("all")
213  @lombok.Generated
214  public void setNoFeedStory(final Boolean noFeedStory) {
215    this.noFeedStory = noFeedStory;
216  }
217
218  @Override
219  @java.lang.SuppressWarnings("all")
220  @lombok.Generated
221  public Comments getComments() {
222    return this.comments;
223  }
224
225  @java.lang.SuppressWarnings("all")
226  @lombok.Generated
227  public void setComments(final Comments comments) {
228    this.comments = comments;
229  }
230
231  @java.lang.SuppressWarnings("all")
232  @lombok.Generated
233  public Likes getLikes() {
234    return this.likes;
235  }
236
237  @java.lang.SuppressWarnings("all")
238  @lombok.Generated
239  public void setLikes(final Likes likes) {
240    this.likes = likes;
241  }
242
243  @java.lang.SuppressWarnings("all")
244  @lombok.Generated
245  public Double getRatingValue() {
246    return this.ratingValue;
247  }
248
249  @java.lang.SuppressWarnings("all")
250  @lombok.Generated
251  public void setRatingValue(final Double ratingValue) {
252    this.ratingValue = ratingValue;
253  }
254
255  @java.lang.SuppressWarnings("all")
256  @lombok.Generated
257  public Long getRatingScale() {
258    return this.ratingScale;
259  }
260
261  @java.lang.SuppressWarnings("all")
262  @lombok.Generated
263  public void setRatingScale(final Long ratingScale) {
264    this.ratingScale = ratingScale;
265  }
266
267  @java.lang.SuppressWarnings("all")
268  @lombok.Generated
269  public String getReviewText() {
270    return this.reviewText;
271  }
272
273  @java.lang.SuppressWarnings("all")
274  @lombok.Generated
275  public void setReviewText(final String reviewText) {
276    this.reviewText = reviewText;
277  }
278
279  @java.lang.SuppressWarnings("all")
280  @lombok.Generated
281  public Boolean getIsDraft() {
282    return this.isDraft;
283  }
284
285  @java.lang.SuppressWarnings("all")
286  @lombok.Generated
287  public void setIsDraft(final Boolean isDraft) {
288    this.isDraft = isDraft;
289  }
290
291  @java.lang.SuppressWarnings("all")
292  @lombok.Generated
293  public String getLanguage() {
294    return this.language;
295  }
296
297  @java.lang.SuppressWarnings("all")
298  @lombok.Generated
299  public void setLanguage(final String language) {
300    this.language = language;
301  }
302
303  @java.lang.SuppressWarnings("all")
304  @lombok.Generated
305  public Place getPlace() {
306    return this.place;
307  }
308
309  @java.lang.SuppressWarnings("all")
310  @lombok.Generated
311  public void setPlace(final Place place) {
312    this.place = place;
313  }
314
315  @java.lang.SuppressWarnings("all")
316  @lombok.Generated
317  public RecommendationType getRecommendationType() {
318    return this.recommendationType;
319  }
320
321  @java.lang.SuppressWarnings("all")
322  @lombok.Generated
323  public void setRecommendationType(final RecommendationType recommendationType) {
324    this.recommendationType = recommendationType;
325  }
326}