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 static java.util.Collections.unmodifiableList; 026import java.util.ArrayList; 027import java.util.List; 028import com.restfb.Facebook; 029import com.restfb.JsonMapper; 030import com.restfb.json.Json; 031import com.restfb.json.JsonObject; 032 033/** 034 * Represents the <a href="https://developers.facebook.com/docs/graph-api/reference/post/reactions">Reactions Type</a> 035 */ 036public class Reactions extends AbstractFacebookType { 037 /** 038 * The number of reactions. 039 */ 040 @Facebook 041 private Long totalCount = 0L; 042 /** 043 * returns the user reaction to the object 044 */ 045 private String viewerReaction; 046 @Facebook 047 private String summary; 048 @Facebook 049 private List<ReactionItem> data = new ArrayList<>(); 050 private static final long serialVersionUID = 1L; 051 052 /** 053 * The reaction list. 054 * 055 * @return The reaction list. 056 */ 057 public List<ReactionItem> getData() { 058 return unmodifiableList(data); 059 } 060 061 public boolean addData(ReactionItem reaction) { 062 return data.add(reaction); 063 } 064 065 public boolean removeData(ReactionItem reaction) { 066 return data.remove(reaction); 067 } 068 069 @JsonMapper.JsonMappingCompleted 070 private void fillFields() { 071 JsonObject summaryObject = null; 072 if (summary != null) { 073 summaryObject = Json.parse(summary).asObject(); 074 } 075 fillViewerReaction(summaryObject); 076 fillTotalCount(summaryObject); 077 } 078 079 private void fillViewerReaction(JsonObject summary) { 080 if (summary != null && summary.get("viewer_reaction") != null) { 081 viewerReaction = summary.get("viewer_reaction").asString(); 082 } 083 } 084 085 /** 086 * add change count value, if summary is set and count is empty 087 */ 088 private void fillTotalCount(JsonObject summary) { 089 if (totalCount == 0 && summary != null && summary.get("total_count") != null) { 090 totalCount = summary.getLong("total_count", totalCount); 091 } 092 } 093 094 095 /** 096 * the reaction type 097 */ 098 public static class ReactionItem extends AbstractFacebookType { 099 /** 100 * the name of the user who sent the reaction 101 */ 102 @Facebook 103 private String name; 104 /** 105 * the id of the user who sent the reaction 106 */ 107 @Facebook 108 private String id; 109 /** 110 * type of the reaction 111 * 112 * may be {NONE, LIKE, LOVE, WOW, HAHA, SAD, ANGRY} 113 */ 114 @Facebook 115 private String type; 116 117 /** 118 * the name of the user who sent the reaction 119 */ 120 @java.lang.SuppressWarnings("all") 121 @lombok.Generated 122 public String getName() { 123 return this.name; 124 } 125 126 /** 127 * the name of the user who sent the reaction 128 */ 129 @java.lang.SuppressWarnings("all") 130 @lombok.Generated 131 public void setName(final String name) { 132 this.name = name; 133 } 134 135 /** 136 * the id of the user who sent the reaction 137 */ 138 @java.lang.SuppressWarnings("all") 139 @lombok.Generated 140 public String getId() { 141 return this.id; 142 } 143 144 /** 145 * the id of the user who sent the reaction 146 */ 147 @java.lang.SuppressWarnings("all") 148 @lombok.Generated 149 public void setId(final String id) { 150 this.id = id; 151 } 152 153 /** 154 * type of the reaction 155 * 156 * may be {NONE, LIKE, LOVE, WOW, HAHA, SAD, ANGRY} 157 * 158 * @return type of the reaction 159 */ 160 @java.lang.SuppressWarnings("all") 161 @lombok.Generated 162 public String getType() { 163 return this.type; 164 } 165 166 /** 167 * type of the reaction 168 * 169 * may be {NONE, LIKE, LOVE, WOW, HAHA, SAD, ANGRY} 170 */ 171 @java.lang.SuppressWarnings("all") 172 @lombok.Generated 173 public void setType(final String type) { 174 this.type = type; 175 } 176 } 177 178 /** 179 * The number of reactions. 180 * 181 * @return The number of reactions. 182 */ 183 @java.lang.SuppressWarnings("all") 184 @lombok.Generated 185 public Long getTotalCount() { 186 return this.totalCount; 187 } 188 189 /** 190 * The number of reactions. 191 */ 192 @java.lang.SuppressWarnings("all") 193 @lombok.Generated 194 public void setTotalCount(final Long totalCount) { 195 this.totalCount = totalCount; 196 } 197 198 /** 199 * @return the user reaction to the object 200 */ 201 @java.lang.SuppressWarnings("all") 202 @lombok.Generated 203 public String getViewerReaction() { 204 return this.viewerReaction; 205 } 206 207 /** 208 * returns the user reaction to the object 209 */ 210 @java.lang.SuppressWarnings("all") 211 @lombok.Generated 212 public void setViewerReaction(final String viewerReaction) { 213 this.viewerReaction = viewerReaction; 214 } 215}