001package org.intellimate.izou.sdk.events;
002
003import org.intellimate.izou.events.EventModel;
004import org.intellimate.izou.events.EventsControllerModel;
005import org.intellimate.izou.sdk.Context;
006import org.intellimate.izou.sdk.util.AddOnModule;
007
008/**
009 * represents an EventsController used for Controlling the dispatching of Events
010 * @author LeanderK
011 * @version 1.0
012 */
013public abstract class EventsController extends AddOnModule implements EventsControllerModel {
014
015    public EventsController(Context context, String ID) {
016        super(context, ID);
017    }
018
019    @Override
020    public boolean controlEventDispatcher(EventModel eventModel) {
021        //noinspection SimplifiableIfStatement
022        if (eventModel.getType().equals(CommonEvents.Type.NOTIFICATION_TYPE) ||
023                eventModel.containsDescriptor(CommonEvents.ALARM_DESCRIPTOR) ||
024                eventModel.containsDescriptor(CommonEvents.Descriptors.STOP_DESCRIPTOR) ||
025                eventModel.containsDescriptor(CommonEvents.Descriptors.NOT_INTERRUPT))
026            return true;
027        return controlEvents(eventModel);
028    }
029
030    /**
031     * Controls whether the fired Event should be dispatched to all the listeners. This method should execute quickly
032     * @param eventModel the Event
033     * @return true if it should dispatch, false if not
034     */
035    public abstract boolean controlEvents(EventModel eventModel);
036}