com.github.messenger4j.send.MessagePayload Maven / Gradle / Ivy
// Generated by delombok at Tue May 07 22:31:27 CEST 2019
package com.github.messenger4j.send;
import static java.util.Optional.empty;
import com.github.messenger4j.send.message.Message;
import com.github.messenger4j.send.recipient.IdRecipient;
import com.github.messenger4j.send.recipient.Recipient;
import java.util.Optional;
import lombok.NonNull;
/**
* @author Max Grabenhorst
* @since 1.0.0
*/
public final class MessagePayload extends Payload {
private final MessagingType messagingType;
private final Message message;
private final Optional notificationType;
private final Optional tag;
private MessagePayload(
Recipient recipient,
MessagingType messagingType,
Message message,
Optional notificationType,
Optional tag) {
super(recipient);
this.messagingType = messagingType;
this.message = message;
this.notificationType = notificationType;
this.tag = tag;
}
public static MessagePayload create(
@NonNull String recipientId, @NonNull MessagingType messagingType, @NonNull Message message) {
if (recipientId == null) {
throw new java.lang.IllegalArgumentException("recipientId is marked @NonNull but is null");
}
if (messagingType == null) {
throw new java.lang.IllegalArgumentException("messagingType is marked @NonNull but is null");
}
if (message == null) {
throw new java.lang.IllegalArgumentException("message is marked @NonNull but is null");
}
return create(IdRecipient.create(recipientId), messagingType, message, empty(), empty());
}
public static MessagePayload create(
@NonNull Recipient recipient,
@NonNull MessagingType messagingType,
@NonNull Message message) {
if (recipient == null) {
throw new java.lang.IllegalArgumentException("recipient is marked @NonNull but is null");
}
if (messagingType == null) {
throw new java.lang.IllegalArgumentException("messagingType is marked @NonNull but is null");
}
if (message == null) {
throw new java.lang.IllegalArgumentException("message is marked @NonNull but is null");
}
return create(recipient, messagingType, message, empty(), empty());
}
public static MessagePayload create(
@NonNull Recipient recipient,
@NonNull MessagingType messagingType,
@NonNull Message message,
@NonNull Optional notificationType,
@NonNull Optional tag) {
if (recipient == null) {
throw new java.lang.IllegalArgumentException("recipient is marked @NonNull but is null");
}
if (messagingType == null) {
throw new java.lang.IllegalArgumentException("messagingType is marked @NonNull but is null");
}
if (message == null) {
throw new java.lang.IllegalArgumentException("message is marked @NonNull but is null");
}
if (notificationType == null) {
throw new java.lang.IllegalArgumentException(
"notificationType is marked @NonNull but is null");
}
if (tag == null) {
throw new java.lang.IllegalArgumentException("tag is marked @NonNull but is null");
}
return new MessagePayload(recipient, messagingType, message, notificationType, tag);
}
public MessagingType messagingType() {
return messagingType;
}
public Message message() {
return message;
}
public Optional notificationType() {
return notificationType;
}
public Optional tag() {
return tag;
}
@java.lang.Override
@java.lang.SuppressWarnings("all")
public java.lang.String toString() {
return "MessagePayload(super="
+ super.toString()
+ ", messagingType="
+ this.messagingType
+ ", message="
+ this.message
+ ", notificationType="
+ this.notificationType
+ ", tag="
+ this.tag
+ ")";
}
@java.lang.Override
@java.lang.SuppressWarnings("all")
public boolean equals(final java.lang.Object o) {
if (o == this) return true;
if (!(o instanceof MessagePayload)) return false;
final MessagePayload other = (MessagePayload) o;
if (!other.canEqual((java.lang.Object) this)) return false;
if (!super.equals(o)) return false;
final java.lang.Object this$messagingType = this.messagingType;
final java.lang.Object other$messagingType = other.messagingType;
if (this$messagingType == null
? other$messagingType != null
: !this$messagingType.equals(other$messagingType)) return false;
final java.lang.Object this$message = this.message;
final java.lang.Object other$message = other.message;
if (this$message == null ? other$message != null : !this$message.equals(other$message))
return false;
final java.lang.Object this$notificationType = this.notificationType;
final java.lang.Object other$notificationType = other.notificationType;
if (this$notificationType == null
? other$notificationType != null
: !this$notificationType.equals(other$notificationType)) return false;
final java.lang.Object this$tag = this.tag;
final java.lang.Object other$tag = other.tag;
if (this$tag == null ? other$tag != null : !this$tag.equals(other$tag)) return false;
return true;
}
@java.lang.SuppressWarnings("all")
protected boolean canEqual(final java.lang.Object other) {
return other instanceof MessagePayload;
}
@java.lang.Override
@java.lang.SuppressWarnings("all")
public int hashCode() {
final int PRIME = 59;
int result = super.hashCode();
final java.lang.Object $messagingType = this.messagingType;
result = result * PRIME + ($messagingType == null ? 43 : $messagingType.hashCode());
final java.lang.Object $message = this.message;
result = result * PRIME + ($message == null ? 43 : $message.hashCode());
final java.lang.Object $notificationType = this.notificationType;
result = result * PRIME + ($notificationType == null ? 43 : $notificationType.hashCode());
final java.lang.Object $tag = this.tag;
result = result * PRIME + ($tag == null ? 43 : $tag.hashCode());
return result;
}
}