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

com.github.messenger4j.receive.callers.AttachmentMessageEventHandlerCaller Maven / Gradle / Ivy

Go to download

The ultimate Java library for building Chatbots on the Facebook Messenger Platform

There is a newer version: 1.1.0
Show newest version
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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy