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.send;
024
025import java.util.ArrayList;
026import java.util.Collections;
027import java.util.List;
028import com.restfb.Facebook;
029import com.restfb.exception.FacebookPreconditionException;
030import com.restfb.types.AbstractFacebookType;
031
032public class ListViewElement extends AbstractFacebookType {
033  @Facebook
034  private String title;
035  @Facebook
036  private String subtitle;
037  @Facebook("image_url")
038  private String imageUrl;
039  @Facebook("default_action")
040  private DefaultAction defaultAction;
041  @Facebook
042  private List<AbstractButton> buttons;
043
044  public ListViewElement(String title) {
045    this.title = title;
046  }
047
048  public boolean addButton(AbstractButton button) {
049    if (buttons == null) {
050      buttons = new ArrayList<>();
051    }
052    if (buttons.size() == 1) {
053      throw new FacebookPreconditionException("maximum of associated buttons is 1");
054    }
055    return buttons.add(button);
056  }
057
058  public List<AbstractButton> getButtons() {
059    if (buttons == null) {
060      return Collections.emptyList();
061    }
062    return Collections.unmodifiableList(buttons);
063  }
064
065  @java.lang.SuppressWarnings("all")
066  public String getTitle() {
067    return this.title;
068  }
069
070  @java.lang.SuppressWarnings("all")
071  public String getSubtitle() {
072    return this.subtitle;
073  }
074
075  @java.lang.SuppressWarnings("all")
076  public void setSubtitle(final String subtitle) {
077    this.subtitle = subtitle;
078  }
079
080  @java.lang.SuppressWarnings("all")
081  public String getImageUrl() {
082    return this.imageUrl;
083  }
084
085  @java.lang.SuppressWarnings("all")
086  public void setImageUrl(final String imageUrl) {
087    this.imageUrl = imageUrl;
088  }
089
090  @java.lang.SuppressWarnings("all")
091  public DefaultAction getDefaultAction() {
092    return this.defaultAction;
093  }
094
095  @java.lang.SuppressWarnings("all")
096  public void setDefaultAction(final DefaultAction defaultAction) {
097    this.defaultAction = defaultAction;
098  }
099}