All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.messenger4j.send.message.template.ListTemplate Maven / Gradle / Ivy

// Generated by delombok at Tue May 07 22:31:27 CEST 2019
package com.github.messenger4j.send.message.template;

import static java.util.Optional.empty;

import com.github.messenger4j.internal.Lists;
import com.github.messenger4j.send.message.template.button.Button;
import com.github.messenger4j.send.message.template.common.Element;
import java.util.List;
import java.util.Optional;
import lombok.NonNull;

/**
 * @author Jan Zarnikov
 * @author Max Grabenhorst
 * @since 1.0.0
 */
public final class ListTemplate extends Template {
  private final List elements;
  private final Optional topElementStyle;
  private final Optional> buttons;

  private ListTemplate(
      List elements,
      Optional topElementStyle,
      Optional> buttons) {
    super(Type.LIST);
    this.elements = Lists.immutableList(elements);
    this.topElementStyle = topElementStyle;
    this.buttons = buttons.map(Lists::immutableList);
  }

  public static ListTemplate create(@NonNull List elements) {
    if (elements == null) {
      throw new java.lang.IllegalArgumentException("elements is marked @NonNull but is null");
    }
    return create(elements, empty(), empty());
  }

  public static ListTemplate create(
      @NonNull List elements,
      @NonNull Optional topElementStyle,
      @NonNull Optional> buttons) {
    if (elements == null) {
      throw new java.lang.IllegalArgumentException("elements is marked @NonNull but is null");
    }
    if (topElementStyle == null) {
      throw new java.lang.IllegalArgumentException(
          "topElementStyle is marked @NonNull but is null");
    }
    if (buttons == null) {
      throw new java.lang.IllegalArgumentException("buttons is marked @NonNull but is null");
    }
    return new ListTemplate(elements, topElementStyle, buttons);
  }

  public List elements() {
    return elements;
  }

  public Optional topElementStyle() {
    return topElementStyle;
  }

  public Optional> buttons() {
    return buttons;
  }

  /** @since 1.0.0 */
  public enum TopElementStyle {
    LARGE,
    COMPACT;
  }

  @java.lang.Override
  @java.lang.SuppressWarnings("all")
  public java.lang.String toString() {
    return "ListTemplate(super="
        + super.toString()
        + ", elements="
        + this.elements
        + ", topElementStyle="
        + this.topElementStyle
        + ", buttons="
        + this.buttons
        + ")";
  }

  @java.lang.Override
  @java.lang.SuppressWarnings("all")
  public boolean equals(final java.lang.Object o) {
    if (o == this) return true;
    if (!(o instanceof ListTemplate)) return false;
    final ListTemplate other = (ListTemplate) o;
    if (!other.canEqual((java.lang.Object) this)) return false;
    if (!super.equals(o)) return false;
    final java.lang.Object this$elements = this.elements;
    final java.lang.Object other$elements = other.elements;
    if (this$elements == null ? other$elements != null : !this$elements.equals(other$elements))
      return false;
    final java.lang.Object this$topElementStyle = this.topElementStyle;
    final java.lang.Object other$topElementStyle = other.topElementStyle;
    if (this$topElementStyle == null
        ? other$topElementStyle != null
        : !this$topElementStyle.equals(other$topElementStyle)) return false;
    final java.lang.Object this$buttons = this.buttons;
    final java.lang.Object other$buttons = other.buttons;
    if (this$buttons == null ? other$buttons != null : !this$buttons.equals(other$buttons))
      return false;
    return true;
  }

  @java.lang.SuppressWarnings("all")
  protected boolean canEqual(final java.lang.Object other) {
    return other instanceof ListTemplate;
  }

  @java.lang.Override
  @java.lang.SuppressWarnings("all")
  public int hashCode() {
    final int PRIME = 59;
    int result = super.hashCode();
    final java.lang.Object $elements = this.elements;
    result = result * PRIME + ($elements == null ? 43 : $elements.hashCode());
    final java.lang.Object $topElementStyle = this.topElementStyle;
    result = result * PRIME + ($topElementStyle == null ? 43 : $topElementStyle.hashCode());
    final java.lang.Object $buttons = this.buttons;
    result = result * PRIME + ($buttons == null ? 43 : $buttons.hashCode());
    return result;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy