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

com.hubspot.blazar.externalservice.slack.SlackAttachment Maven / Gradle / Ivy

The newest version!
package com.hubspot.blazar.externalservice.slack;

import java.util.List;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Objects;
import com.google.common.base.Optional;

public class SlackAttachment {
  private static final Optional ABSENT_STRING = Optional.absent();

  private final String fallback;
  private final Optional color;
  private final Optional pretext;

  // author
  private final Optional authorName;
  private final Optional authorLink;
  private final Optional authorIcon;

  // title
  private final Optional title;
  private final Optional titleLink;

  private final Optional text;

  private final List fields;

  private final Optional thumbUrl;

  @JsonCreator
  public SlackAttachment(
      @JsonProperty("fallback") String fallback,
      @JsonProperty("color") Optional color,
      @JsonProperty("pretext") Optional pretext,
      @JsonProperty("author_name") Optional authorName,
      @JsonProperty("author_link") Optional authorLink,
      @JsonProperty("author_icon") Optional authorIcon,
      @JsonProperty("title") Optional title,
      @JsonProperty("title_link") Optional titleLink,
      @JsonProperty("text") Optional text,
      @JsonProperty("fields") List fields,
      @JsonProperty("thumb_url") Optional thumbUrl) {

    this.fallback = fallback;
    this.color = Objects.firstNonNull(color, ABSENT_STRING);
    this.pretext = Objects.firstNonNull(pretext, ABSENT_STRING);
    this.authorName = Objects.firstNonNull(authorName, ABSENT_STRING);
    this.authorLink = Objects.firstNonNull(authorLink, ABSENT_STRING);
    this.authorIcon = Objects.firstNonNull(authorIcon, ABSENT_STRING);
    this.title = Objects.firstNonNull(title, ABSENT_STRING);
    this.titleLink = Objects.firstNonNull(titleLink, ABSENT_STRING);
    this.text = Objects.firstNonNull(text, ABSENT_STRING);
    this.fields = fields;
    this.thumbUrl = Objects.firstNonNull(thumbUrl, ABSENT_STRING);
  }

  public String getFallback() {
    return fallback;
  }

  public Optional getColor() {
    return color;
  }

  public Optional getPretext() {
    return pretext;
  }

  @JsonProperty("author_name")
  public Optional getAuthorName() {
    return authorName;
  }

  @JsonProperty("author_link")
  public Optional getAuthorLink() {
    return authorLink;
  }

  @JsonProperty("author_icon")
  public Optional getAuthorIcon() {
    return authorIcon;
  }

  public Optional getTitle() {
    return title;
  }

  @JsonProperty("title_link")
  public Optional getTitleLink() {
    return titleLink;
  }

  public Optional getText() {
    return text;
  }

  public List getFields() {
    return fields;
  }

  @JsonProperty("thumb_url")
  public Optional getThumbUrl() {
    return thumbUrl;
  }

  @Override public String toString() {
    return Objects.toStringHelper(this)
        .add("fallback", fallback)
        .add("color", color)
        .add("pretext", pretext)
        .add("authorName", authorName)
        .add("authorLink", authorLink)
        .add("authorIcon", authorIcon)
        .add("title", title)
        .add("titleLink", titleLink)
        .add("text", text)
        .add("fields", fields)
        .add("thumbUrl", thumbUrl)
        .toString();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy