// Path: app/src/main/java/com/tonilopezmr/sample/domain/Subject.java
// public class Subject {
// 
//     private int id;
//     private String name;
// 
//     public Subject(String name) {
//         this.name = name;
//     }
// 
//     public Subject(int id, String name) {
//         this.id = id;
//         this.name = name;
//     }
// 
//     public int getId() {
//         return id;
//     }
// 
//     public void setId(int id) {
//         this.id = id;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public void setName(String name) {
//         this.name = name;
//     }
// 
//     @Override
//     public String toString() {
//         return "ID: "+this.id+" Subject: "+this.name;
//     }
// }
// 
// Path: app/src/main/java/com/tonilopezmr/sample/domain/exception/SubjectException.java
// public class SubjectException extends RuntimeException {
// 
//     private String message;
// 
//     public SubjectException(String detailMessage) {
//         super(detailMessage);
//         this.message = detailMessage;
//     }
// 
//     public SubjectException(Exception exception) {
//         this.setStackTrace(exception.getStackTrace());
//         this.message = exception.getMessage();
//     }
// 
//     @Override
//     public String getMessage() {
//         return message;
//     }
// }
// 
// Path: app/src/main/java/com/tonilopezmr/sample/domain/repository/SubjectRepository.java
// public interface SubjectRepository {
// 
//     interface SubjectListCallback {
//         void onSubjectListLoader(Collection<Subject> subjects);
//         void onError(SubjectException subjectException);
//     }
// 
//     interface SubjectUseCase {
//         void onMissionAccomplished(Subject subject);
//         void onError(SubjectException subjectException);
//     }
// 
//     void getSubjectsCollection(SubjectListCallback callback) throws SubjectException;
// 
//     void createSubject(Subject subject, SubjectUseCase callback) throws SubjectException;
//     void deleteSubject(Subject subject, SubjectUseCase callback) throws  SubjectException;
// }
// 
// Path: app/src/main/java/com/tonilopezmr/sample/executor/Executor.java
// public interface Executor {
//     void run(final Interactor interactor);
// }
// 
// Path: app/src/main/java/com/tonilopezmr/sample/executor/MainThread.java
// public interface MainThread {
//     void post(final Runnable runnable);
// }


import com.tonilopezmr.sample.domain.Subject;
import com.tonilopezmr.sample.domain.exception.SubjectException;
import com.tonilopezmr.sample.domain.repository.SubjectRepository;
import com.tonilopezmr.sample.executor.Executor;
import com.tonilopezmr.sample.executor.MainThread;
package com.tonilopezmr.sample.domain.interactor;


/**
 * @author toni.
 */
public class CreateSubjectUseCaseImp extends AbstractSubjectUseCase implements SubjectUseCase {

    private Callback callback;
    private Subject subject;

    public CreateSubjectUseCaseImp(Executor executor, MainThread mainThread, SubjectRepository subjectRepository) {
        super(executor, mainThread, subjectRepository);
    }

    @Override
    public void execute(Subject subject, final Callback callback) {
        if (callback == null){
            throw new IllegalArgumentException("Callback parameter can't be null");
        }

        this.callback = callback;
        this.subject = subject;
        super.executor.run(this);
    }


    //Interactor Use case
    @Override
    public void run() {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

// Path: app/src/main/java/com/tonilopezmr/sample/domain/Subject.java
// public class Subject {
// 
//     private int id;
//     private String name;
// 
//     public Subject(String name) {
//         this.name = name;
//     }
// 
//     public Subject(int id, String name) {
//         this.id = id;
//         this.name = name;
//     }
// 
//     public int getId() {
//         return id;
//     }
// 
//     public void setId(int id) {
//         this.id = id;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public void setName(String name) {
//         this.name = name;
//     }
// 
//     @Override
//     public String toString() {
//         return "ID: "+this.id+" Subject: "+this.name;
//     }
// }
// 
// Path: app/src/main/java/com/tonilopezmr/sample/domain/exception/SubjectException.java
// public class SubjectException extends RuntimeException {
// 
//     private String message;
// 
//     public SubjectException(String detailMessage) {
//         super(detailMessage);
//         this.message = detailMessage;
//     }
// 
//     public SubjectException(Exception exception) {
//         this.setStackTrace(exception.getStackTrace());
//         this.message = exception.getMessage();
//     }
// 
//     @Override
//     public String getMessage() {
//         return message;
//     }
// }
// 
// Path: app/src/main/java/com/tonilopezmr/sample/domain/repository/SubjectRepository.java
// public interface SubjectRepository {
// 
//     interface SubjectListCallback {
//         void onSubjectListLoader(Collection<Subject> subjects);
//         void onError(SubjectException subjectException);
//     }
// 
//     interface SubjectUseCase {
//         void onMissionAccomplished(Subject subject);
//         void onError(SubjectException subjectException);
//     }
// 
//     void getSubjectsCollection(SubjectListCallback callback) throws SubjectException;
// 
//     void createSubject(Subject subject, SubjectUseCase callback) throws SubjectException;
//     void deleteSubject(Subject subject, SubjectUseCase callback) throws  SubjectException;
// }
// 
// Path: app/src/main/java/com/tonilopezmr/sample/executor/Executor.java
// public interface Executor {
//     void run(final Interactor interactor);
// }
// 
// Path: app/src/main/java/com/tonilopezmr/sample/executor/MainThread.java
// public interface MainThread {
//     void post(final Runnable runnable);
// }


// Path: app/src/main/java/com/tonilopezmr/sample/domain/interactor/CreateSubjectUseCaseImp.java
import com.tonilopezmr.sample.domain.Subject;
import com.tonilopezmr.sample.domain.exception.SubjectException;
import com.tonilopezmr.sample.domain.repository.SubjectRepository;
import com.tonilopezmr.sample.executor.Executor;
import com.tonilopezmr.sample.executor.MainThread;

package com.tonilopezmr.sample.domain.interactor;


/**
 * @author toni.
 */
public class CreateSubjectUseCaseImp extends AbstractSubjectUseCase implements SubjectUseCase {

    private Callback callback;
    private Subject subject;

    public CreateSubjectUseCaseImp(Executor executor, MainThread mainThread, SubjectRepository subjectRepository) {
        super(executor, mainThread, subjectRepository);
    }

    @Override
    public void execute(Subject subject, final Callback callback) {
        if (callback == null){
            throw new IllegalArgumentException("Callback parameter can't be null");
        }

        this.callback = callback;
        this.subject = subject;
        super.executor.run(this);
    }


    //Interactor Use case
    @Override
    public void run() {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        super.subjectRepository.createSubject(this.subject, new SubjectRepository.SubjectUseCase() {