com.viber.bot.event.incoming.IncomingMessageEvent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of viber-bot Show documentation
Show all versions of viber-bot Show documentation
Use this library to communicate with the Viber API to develop a bot for https://developers.viber.com/.
The newest version!
package com.viber.bot.event.incoming;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.viber.bot.event.Event;
import com.viber.bot.message.Message;
import com.viber.bot.profile.UserProfile;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
import static com.google.common.base.Preconditions.checkNotNull;
@Immutable
public class IncomingMessageEvent extends IncomingEvent {
private final Long token;
private final Message message;
private final UserProfile sender;
@Nullable
private final String chatId;
@Nullable
private final String replyType;
private final boolean receivedAsSilent;
@JsonCreator
IncomingMessageEvent(final @JsonProperty("message") @Nonnull Message message,
final @JsonProperty("sender") @Nonnull UserProfile sender,
final @JsonProperty("message_token") long token,
final @JsonProperty("timestamp") long timestamp,
final @JsonProperty("silent") boolean receivedAsSilent,
final @JsonProperty("chat_id") @Nullable String chatId,
final @JsonProperty("reply_type") @Nullable String replyType) {
super(Event.MESSAGE_RECEIVED, timestamp);
this.message = checkNotNull(message);
this.sender = checkNotNull(sender);
this.token = token;
this.chatId = chatId;
this.replyType = replyType;
this.receivedAsSilent = receivedAsSilent;
}
public Long getToken() {
return token;
}
public Message getMessage() {
return message;
}
public UserProfile getSender() {
return sender;
}
@Nullable
public String getChatId() {
return chatId;
}
@Nullable
public String getReplyType() {
return replyType;
}
public boolean hasReceivedAsSilent() {
return receivedAsSilent;
}
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
final IncomingMessageEvent that = (IncomingMessageEvent) o;
if (token != null ? !token.equals(that.token) : that.token != null) return false;
if (message != null ? !message.equals(that.message) : that.message != null) return false;
if (sender != null ? !sender.equals(that.sender) : that.sender != null) return false;
if (chatId != null ? !chatId.equals(that.chatId) : that.chatId != null) return false;
if (replyType != null ? !replyType.equals(that.replyType) : that.replyType != null) return false;
if (receivedAsSilent != that.receivedAsSilent) return false;
return true;
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (token != null ? token.hashCode() : 0);
result = 31 * result + (message != null ? message.hashCode() : 0);
result = 31 * result + (sender != null ? sender.hashCode() : 0);
result = 31 * result + (chatId != null ? chatId.hashCode() : 0);
result = 31 * result + (replyType != null ? replyType.hashCode() : 0);
result = 31 * result + Boolean.hashCode(receivedAsSilent);
return result;
}
}