001// Generated by delombok at Fri Oct 04 16:05:59 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.webhook.messaging;
024
025import com.restfb.Facebook;
026import com.restfb.JsonMapper;
027
028public class MessagingAttachment {
029  /**
030   * The "audio" attachment type.
031   */
032  public static final String AUDIO = "audio";
033  /**
034   * The "fallback" attachment type.
035   */
036  public static final String FALLBACK = "fallback";
037  /**
038   * The "file" attachment type.
039   */
040  public static final String FILE = "file";
041  /**
042   * The "image" attachment type.
043   */
044  public static final String IMAGE = "image";
045  /**
046   * The "location" attachment type.
047   */
048  public static final String LOCATION = "location";
049  /**
050   * The "video" attachment type.
051   */
052  public static final String VIDEO = "video";
053  /**
054   * The "unsupported type" attachment type
055   */
056  public static final String UNSUPPORTED_TYPE = "unsupported_type";
057  /**
058   * The "template" attachment type.
059   */
060  public static final String TEMPLATE = "template";
061  /**
062   * The "story_mention" attachment type.
063   */
064  public static final String STORY_MENTION = "story_mention";
065  @Facebook
066  private String type;
067  @Facebook
068  private String title;
069  @Facebook
070  private String url;
071  @Facebook("payload")
072  private String fallbackPayload;
073  @Facebook
074  private MessagingPayload payload;
075
076  @JsonMapper.JsonMappingCompleted
077  private void selectPayload() {
078    if (payload == null) {
079      payload = new MessagingPayload();
080      payload.setFallback(fallbackPayload);
081    }
082  }
083
084  /**
085   * convenience method to check if the attachment type is audio
086   *
087   * @return {@code true} if audio, {@code false} if not audio
088   */
089  public boolean isAudio() {
090    return AUDIO.equals(type);
091  }
092
093  /**
094   * convenience method to check if the attachment type is fallback
095   *
096   * @return {@code true} if fallback, {@code false} if not fallback
097   */
098  public boolean isFallback() {
099    return FALLBACK.equals(type);
100  }
101
102  /**
103   * convenience method to check if the attachment type is file
104   *
105   * @return {@code true} if file, {@code false} if not file
106   */
107  public boolean isFile() {
108    return FILE.equals(type);
109  }
110
111  /**
112   * convenience method to check if the attachment type is image
113   *
114   * @return {@code true} if image, {@code false} if not image
115   */
116  public boolean isImage() {
117    return IMAGE.equals(type);
118  }
119
120  /**
121   * convenience method to check if the attachment type is location
122   *
123   * @return {@code true} if location, {@code false} if not location
124   */
125  public boolean isLocation() {
126    return LOCATION.equals(type);
127  }
128
129  /**
130   * convenience method to check if the attachment type is video
131   *
132   * @return {@code true} if video, {@code false} if not video
133   */
134  public boolean isVideo() {
135    return VIDEO.equals(type);
136  }
137
138  /**
139   * convenience method to check if the attachment type is template
140   *
141   * @return {@code true} if template, {@code false} if not template
142   */
143  public boolean isTemplate() {
144    return TEMPLATE.equals(type);
145  }
146
147  /**
148   * convenience method to check if the attachment type is unsupported
149   *
150   * @return {@code true} if unsupported type, {@code false} if supported
151   */
152  public boolean isUnsupportedType() {
153    return UNSUPPORTED_TYPE.equals(type);
154  }
155
156  /**
157   * convenience method to check if the attachment type is story_mention
158   *
159   * @return {@code true} if story_mention type, {@code false} if not story_mention
160   */
161  public boolean isStoryMention() {
162    return STORY_MENTION.equals(type);
163  }
164
165  @java.lang.Override
166  @java.lang.SuppressWarnings("all")
167  public java.lang.String toString() {
168    return "MessagingAttachment(type=" + this.getType() + ", title=" + this.getTitle() + ", url=" + this.getUrl() + ", fallbackPayload=" + this.fallbackPayload + ", payload=" + this.getPayload() + ")";
169  }
170
171  @java.lang.SuppressWarnings("all")
172  public String getType() {
173    return this.type;
174  }
175
176  @java.lang.SuppressWarnings("all")
177  public void setType(final String type) {
178    this.type = type;
179  }
180
181  @java.lang.SuppressWarnings("all")
182  public String getTitle() {
183    return this.title;
184  }
185
186  @java.lang.SuppressWarnings("all")
187  public void setTitle(final String title) {
188    this.title = title;
189  }
190
191  @java.lang.SuppressWarnings("all")
192  public String getUrl() {
193    return this.url;
194  }
195
196  @java.lang.SuppressWarnings("all")
197  public void setUrl(final String url) {
198    this.url = url;
199  }
200
201  @java.lang.SuppressWarnings("all")
202  public MessagingPayload getPayload() {
203    return this.payload;
204  }
205
206  @java.lang.SuppressWarnings("all")
207  public void setPayload(final MessagingPayload payload) {
208    this.payload = payload;
209  }
210}