001// Generated by delombok at Fri Oct 09 16:27:16 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.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  @Facebook
054  private String type;
055  @Facebook
056  private String title;
057  @Facebook
058  private String url;
059  @Facebook("payload")
060  private String fallbackPayload;
061  @Facebook
062  private MessagingPayload payload;
063
064  @JsonMapper.JsonMappingCompleted
065  private void selectPayload() {
066    if (payload == null) {
067      payload = new MessagingPayload();
068      payload.setFallback(fallbackPayload);
069    }
070  }
071
072  /**
073   * convenience method to check if the attachment type is audio
074   *
075   * @return {@code true} if audio, {@code false} if not audio
076   */
077  public boolean isAudio() {
078    return AUDIO.equals(type);
079  }
080
081  /**
082   * convenience method to check if the attachment type is fallback
083   *
084   * @return {@code true} if fallback, {@code false} if not fallback
085   */
086  public boolean isFallback() {
087    return FALLBACK.equals(type);
088  }
089
090  /**
091   * convenience method to check if the attachment type is file
092   *
093   * @return {@code true} if file, {@code false} if not file
094   */
095  public boolean isFile() {
096    return FILE.equals(type);
097  }
098
099  /**
100   * convenience method to check if the attachment type is image
101   *
102   * @return {@code true} if image, {@code false} if not image
103   */
104  public boolean isImage() {
105    return IMAGE.equals(type);
106  }
107
108  /**
109   * convenience method to check if the attachment type is location
110   *
111   * @return {@code true} if location, {@code false} if not location
112   */
113  public boolean isLocation() {
114    return LOCATION.equals(type);
115  }
116
117  /**
118   * convenience method to check if the attachment type is video
119   *
120   * @return {@code true} if video, {@code false} if not video
121   */
122  public boolean isVideo() {
123    return VIDEO.equals(type);
124  }
125
126  @java.lang.Override
127  @java.lang.SuppressWarnings("all")
128  public java.lang.String toString() {
129    return "MessagingAttachment(type=" + this.getType() + ", title=" + this.getTitle() + ", url=" + this.getUrl() + ", fallbackPayload=" + this.fallbackPayload + ", payload=" + this.getPayload() + ")";
130  }
131
132  @java.lang.SuppressWarnings("all")
133  public String getType() {
134    return this.type;
135  }
136
137  @java.lang.SuppressWarnings("all")
138  public void setType(final String type) {
139    this.type = type;
140  }
141
142  @java.lang.SuppressWarnings("all")
143  public String getTitle() {
144    return this.title;
145  }
146
147  @java.lang.SuppressWarnings("all")
148  public void setTitle(final String title) {
149    this.title = title;
150  }
151
152  @java.lang.SuppressWarnings("all")
153  public String getUrl() {
154    return this.url;
155  }
156
157  @java.lang.SuppressWarnings("all")
158  public void setUrl(final String url) {
159    this.url = url;
160  }
161
162  @java.lang.SuppressWarnings("all")
163  public MessagingPayload getPayload() {
164    return this.payload;
165  }
166
167  @java.lang.SuppressWarnings("all")
168  public void setPayload(final MessagingPayload payload) {
169    this.payload = payload;
170  }
171}