com.github.messenger4j.send.message.TextMessage Maven / Gradle / Ivy
// Generated by delombok at Tue May 07 22:31:27 CEST 2019
package com.github.messenger4j.send.message;
import static java.util.Optional.empty;
import com.github.messenger4j.send.message.quickreply.QuickReply;
import java.util.List;
import java.util.Optional;
import lombok.NonNull;
/**
* @author Max Grabenhorst
* @since 1.0.0
*/
public final class TextMessage extends Message {
private final String text;
private TextMessage(
String text, Optional> quickReplies, Optional metadata) {
super(quickReplies, metadata);
this.text = text;
}
public static TextMessage create(@NonNull String text) {
if (text == null) {
throw new java.lang.IllegalArgumentException("text is marked @NonNull but is null");
}
return create(text, empty(), empty());
}
public static TextMessage create(
@NonNull String text,
@NonNull Optional> quickReplies,
@NonNull Optional metadata) {
if (text == null) {
throw new java.lang.IllegalArgumentException("text is marked @NonNull but is null");
}
if (quickReplies == null) {
throw new java.lang.IllegalArgumentException("quickReplies is marked @NonNull but is null");
}
if (metadata == null) {
throw new java.lang.IllegalArgumentException("metadata is marked @NonNull but is null");
}
return new TextMessage(text, quickReplies, metadata);
}
public String text() {
return text;
}
@java.lang.Override
@java.lang.SuppressWarnings("all")
public java.lang.String toString() {
return "TextMessage(super=" + super.toString() + ", text=" + this.text + ")";
}
@java.lang.Override
@java.lang.SuppressWarnings("all")
public boolean equals(final java.lang.Object o) {
if (o == this) return true;
if (!(o instanceof TextMessage)) return false;
final TextMessage other = (TextMessage) o;
if (!other.canEqual((java.lang.Object) this)) return false;
if (!super.equals(o)) 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;
return true;
}
@java.lang.SuppressWarnings("all")
protected boolean canEqual(final java.lang.Object other) {
return other instanceof TextMessage;
}
@java.lang.Override
@java.lang.SuppressWarnings("all")
public int hashCode() {
final int PRIME = 59;
int result = super.hashCode();
final java.lang.Object $text = this.text;
result = result * PRIME + ($text == null ? 43 : $text.hashCode());
return result;
}
}