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

com.github.messenger4j.webhook.event.TextMessageEvent Maven / Gradle / Ivy

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

import com.github.messenger4j.webhook.event.common.PriorMessage;
import com.github.messenger4j.webhook.event.nlp.NLPEntity;
import java.time.Instant;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import lombok.NonNull;

/**
 * @author Max Grabenhorst
 * @since 1.0.0
 */
public final class TextMessageEvent extends BaseEvent {
  private final String messageId;
  private final String text;
  private final Optional>> nlpEntities;
  private final Optional priorMessage;

  public TextMessageEvent(
      @NonNull String senderId,
      @NonNull String recipientId,
      @NonNull Instant timestamp,
      @NonNull String messageId,
      @NonNull String text,
      @NonNull Optional>> nlpEntities,
      @NonNull Optional priorMessage) {
    super(senderId, recipientId, timestamp);
    if (senderId == null) {
      throw new java.lang.IllegalArgumentException("senderId is marked @NonNull but is null");
    }
    if (recipientId == null) {
      throw new java.lang.IllegalArgumentException("recipientId is marked @NonNull but is null");
    }
    if (timestamp == null) {
      throw new java.lang.IllegalArgumentException("timestamp is marked @NonNull but is null");
    }
    if (messageId == null) {
      throw new java.lang.IllegalArgumentException("messageId is marked @NonNull but is null");
    }
    if (text == null) {
      throw new java.lang.IllegalArgumentException("text is marked @NonNull but is null");
    }
    if (nlpEntities == null) {
      throw new java.lang.IllegalArgumentException("nlpEntities is marked @NonNull but is null");
    }
    if (priorMessage == null) {
      throw new java.lang.IllegalArgumentException("priorMessage is marked @NonNull but is null");
    }
    this.messageId = messageId;
    this.text = text;
    this.nlpEntities =
        nlpEntities.map(entities -> Collections.unmodifiableMap(new HashMap<>(entities)));
    this.priorMessage = priorMessage;
  }

  public String messageId() {
    return messageId;
  }

  public String text() {
    return text;
  }

  public Optional>> nlpEntities() {
    return nlpEntities;
  }

  public Optional priorMessage() {
    return priorMessage;
  }

  @java.lang.Override
  @java.lang.SuppressWarnings("all")
  public java.lang.String toString() {
    return "TextMessageEvent(super="
        + super.toString()
        + ", messageId="
        + this.messageId
        + ", text="
        + this.text
        + ", nlpEntities="
        + this.nlpEntities
        + ", priorMessage="
        + this.priorMessage
        + ")";
  }

  @java.lang.Override
  @java.lang.SuppressWarnings("all")
  public boolean equals(final java.lang.Object o) {
    if (o == this) return true;
    if (!(o instanceof TextMessageEvent)) return false;
    final TextMessageEvent other = (TextMessageEvent) o;
    if (!other.canEqual((java.lang.Object) this)) return false;
    if (!super.equals(o)) return false;
    final java.lang.Object this$messageId = this.messageId;
    final java.lang.Object other$messageId = other.messageId;
    if (this$messageId == null ? other$messageId != null : !this$messageId.equals(other$messageId))
      return false;
    final java.lang.Object this$text = this.text;
    final java.lang.Object other$text = other.text;
    if (this$text == null ? other$text != null : !this$text.equals(other$text)) return false;
    final java.lang.Object this$nlpEntities = this.nlpEntities;
    final java.lang.Object other$nlpEntities = other.nlpEntities;
    if (this$nlpEntities == null
        ? other$nlpEntities != null
        : !this$nlpEntities.equals(other$nlpEntities)) return false;
    final java.lang.Object this$priorMessage = this.priorMessage;
    final java.lang.Object other$priorMessage = other.priorMessage;
    if (this$priorMessage == null
        ? other$priorMessage != null
        : !this$priorMessage.equals(other$priorMessage)) return false;
    return true;
  }

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy