// Path: bus/src/main/java/com/marcohc/architecture/aca/presentation/bus/data/error/DataException.java
// public class DataException extends Exception {
// 
//     public DataException() {
//     }
// 
//     public DataException(String detailMessage) {
//         super(detailMessage);
//     }
// 
//     public DataException(String detailMessage, Throwable throwable) {
//         super(detailMessage, throwable);
//     }
// 
//     public DataException(Throwable throwable) {
//         super(throwable);
//     }
// 
// }
// 
// Path: bus/src/main/java/com/marcohc/architecture/aca/presentation/bus/domain/exception/DomainException.java
// public class DomainException extends Exception {
// 
//     public DomainException() {
//     }
// 
//     public DomainException(String detailMessage) {
//         super(detailMessage);
//     }
// 
//     public DomainException(String detailMessage, Throwable throwable) {
//         super(detailMessage, throwable);
//     }
// 
//     public DomainException(Throwable throwable) {
//         super(throwable);
//     }
// 
// }
// 
// Path: bus/src/main/java/com/marcohc/architecture/aca/presentation/bus/common/BusEvent.java
// public interface BusEvent {
// }
// 
// Path: bus/src/main/java/com/marcohc/architecture/aca/presentation/bus/common/BusHandler.java
// public abstract class BusHandler {
// 
//     public BusHandler() {
//         registerToBus();
//     }
// 
//     protected void registerToBus() {
//         BusProvider.register(this);
//     }
// 
//     protected void unregisterFromBus() {
//         BusProvider.unregister(this);
//     }
// 
//     protected void post(Object busEvent) {
//         BusProvider.post(busEvent);
//     }
// 
//     protected void postSticky(Object busEvent) {
//         BusProvider.postSticky(busEvent);
//     }
// }


import com.marcohc.architecture.aca.presentation.bus.data.error.DataException;
import com.marcohc.architecture.aca.presentation.bus.domain.exception.DomainException;
import com.marcohc.architecture.aca.presentation.bus.common.BusEvent;
import com.marcohc.architecture.aca.presentation.bus.common.BusHandler;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
package com.marcohc.architecture.aca.presentation.bus.domain.interactor;



/**
 * This class represents an asynchronous use case connected to the bus.
 * Always listening for {@link DataException} which occurs in the data layer
 */
public abstract class AsynchronousUseCase extends BusHandler implements BusUseCase {

    protected abstract BusEvent createRequest();

    protected abstract BusEvent createResponse();

    /**
     * Executes the logic of the use case
     *
     * @return null, the use case is executed asynchronously so the result will be delivered in other ways
     */
    @Override
    public Void execute() {
        BusEvent request = createRequest();
        if (request != null) {
            post(request);
        }
        return null;
    }

    @Subscribe(threadMode = ThreadMode.ASYNC)
    public void onDataException(DataException dataException) {
        handleDataException(dataException);
    }

    /**
     * Converts the {@link DataException} to {@link DomainException} to be handle by presenter.
     * Override this method if you want to customize your data error handling
     */
// Path: bus/src/main/java/com/marcohc/architecture/aca/presentation/bus/data/error/DataException.java
// public class DataException extends Exception {
// 
//     public DataException() {
//     }
// 
//     public DataException(String detailMessage) {
//         super(detailMessage);
//     }
// 
//     public DataException(String detailMessage, Throwable throwable) {
//         super(detailMessage, throwable);
//     }
// 
//     public DataException(Throwable throwable) {
//         super(throwable);
//     }
// 
// }
// 
// Path: bus/src/main/java/com/marcohc/architecture/aca/presentation/bus/domain/exception/DomainException.java
// public class DomainException extends Exception {
// 
//     public DomainException() {
//     }
// 
//     public DomainException(String detailMessage) {
//         super(detailMessage);
//     }
// 
//     public DomainException(String detailMessage, Throwable throwable) {
//         super(detailMessage, throwable);
//     }
// 
//     public DomainException(Throwable throwable) {
//         super(throwable);
//     }
// 
// }
// 
// Path: bus/src/main/java/com/marcohc/architecture/aca/presentation/bus/common/BusEvent.java
// public interface BusEvent {
// }
// 
// Path: bus/src/main/java/com/marcohc/architecture/aca/presentation/bus/common/BusHandler.java
// public abstract class BusHandler {
// 
//     public BusHandler() {
//         registerToBus();
//     }
// 
//     protected void registerToBus() {
//         BusProvider.register(this);
//     }
// 
//     protected void unregisterFromBus() {
//         BusProvider.unregister(this);
//     }
// 
//     protected void post(Object busEvent) {
//         BusProvider.post(busEvent);
//     }
// 
//     protected void postSticky(Object busEvent) {
//         BusProvider.postSticky(busEvent);
//     }
// }


// Path: bus/src/main/java/com/marcohc/architecture/aca/presentation/bus/domain/interactor/AsynchronousUseCase.java
import com.marcohc.architecture.aca.presentation.bus.data.error.DataException;
import com.marcohc.architecture.aca.presentation.bus.domain.exception.DomainException;
import com.marcohc.architecture.aca.presentation.bus.common.BusEvent;
import com.marcohc.architecture.aca.presentation.bus.common.BusHandler;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

package com.marcohc.architecture.aca.presentation.bus.domain.interactor;



/**
 * This class represents an asynchronous use case connected to the bus.
 * Always listening for {@link DataException} which occurs in the data layer
 */
public abstract class AsynchronousUseCase extends BusHandler implements BusUseCase {

    protected abstract BusEvent createRequest();

    protected abstract BusEvent createResponse();

    /**
     * Executes the logic of the use case
     *
     * @return null, the use case is executed asynchronously so the result will be delivered in other ways
     */
    @Override
    public Void execute() {
        BusEvent request = createRequest();
        if (request != null) {
            post(request);
        }
        return null;
    }

    @Subscribe(threadMode = ThreadMode.ASYNC)
    public void onDataException(DataException dataException) {
        handleDataException(dataException);
    }

    /**
     * Converts the {@link DataException} to {@link DomainException} to be handle by presenter.
     * Override this method if you want to customize your data error handling
     */
    protected void handleDataException(DataException dataException) {