com.github.messenger4j.receive.callers.AttachmentMessageEventHandlerCaller Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of messenger4j Show documentation
Show all versions of messenger4j Show documentation
The ultimate Java library for building Chatbots on the Facebook Messenger Platform
package com.github.messenger4j.receive.callers;
import static com.github.messenger4j.internal.JsonHelper.Constants.PROP_ATTACHMENTS;
import static com.github.messenger4j.internal.JsonHelper.Constants.PROP_IS_ECHO;
import static com.github.messenger4j.internal.JsonHelper.Constants.PROP_MESSAGE;
import static com.github.messenger4j.internal.JsonHelper.hasProperty;
import com.github.messenger4j.receive.events.AttachmentMessageEvent;
import com.github.messenger4j.receive.handlers.EventHandler;
import com.github.messenger4j.receive.handlers.FallbackEventHandler;
import com.google.gson.JsonObject;
/**
* Internal {@link EventHandlerCaller} responsible for the {@link AttachmentMessageEvent}.
*
* @author Max Grabenhorst
* @since 0.6.0
* @see EventHandlerCaller
* @see EventHandler
* @see FallbackEventHandler
* @see AttachmentMessageEvent
*/
public final class AttachmentMessageEventHandlerCaller extends EventHandlerCaller {
public AttachmentMessageEventHandlerCaller(EventHandler eventHandler,
FallbackEventHandler fallbackEventHandler) {
super(eventHandler, fallbackEventHandler);
}
@Override
boolean isResponsible(JsonObject messagingEvent) {
return hasProperty(messagingEvent, PROP_MESSAGE, PROP_ATTACHMENTS) &&
!hasProperty(messagingEvent, PROP_MESSAGE, PROP_IS_ECHO);
}
@Override
AttachmentMessageEvent createEventFromJson(JsonObject messagingEvent) {
return AttachmentMessageEvent.fromJson(messagingEvent);
}
}