// Path: core/src/main/java/com/github/ehe/simpleorchestrator/exception/OrchestratorException.java
// public class OrchestratorException extends RuntimeException {
// 
//     private static final long serialVersionUID = 1L;
// 
//     private int errorCode = 0;
// 
//     public OrchestratorException(String msg, Throwable cause) {
//         super(msg, cause);
//     }
// 
//     public OrchestratorException(String msg, int errorCode) {
//         super(msg);
//         this.errorCode = errorCode;
//     }
// 
//     public OrchestratorException(String msg, int errorCode, Throwable cause) {
//         super(msg, cause);
//         this.errorCode = errorCode;
//     }
// 
//     public int getErrorCode() {
//         return errorCode;
//     }
// }
// 
// Path: samples/src/main/java/com/github/ehe/simpleorchestrator/sample/context/AsyncCheckRiskContext.java
// public interface AsyncCheckRiskContext extends HistoryContext<String> {
//     String getSsn();
//     void setRiskScore(Future<Integer> score);
// }
// 
// Path: samples/src/main/java/com/github/ehe/simpleorchestrator/sample/context/CreditScoreContext.java
// public interface CreditScoreContext extends HistoryContext<String> {
//     String getSsn();
//     void setCreditScore(int score);
// }
// 
// Path: samples/src/main/java/com/github/ehe/simpleorchestrator/sample/context/LoanContext.java
// public interface LoanContext extends HistoryContext<String> {
//     LoanApplication getApplication();
//     int getCreditScore();
//     int getRiskScore();
//     void setLoanApproveStatus(boolean isApproved);
// }
// 
// Path: samples/src/main/java/com/github/ehe/simpleorchestrator/sample/context/ValidationContext.java
// public interface ValidationContext<A> extends HistoryContext<String> {
//     A getApplication();
// }
// 
// Path: samples/src/main/java/com/github/ehe/simpleorchestrator/sample/entity/LoanApplication.java
// public class LoanApplication {
// 
//     @NotNull
//     @Valid
//     private Person person;
// 
//     @Valid
//     private Address address;
// 
//     private String occupation;
// 
//     private int salary;
// 
//     private int loanAmount;
// 
//     public LoanApplication(Person person, Address address, String occupation, int salary, int loadAmount) {
//         this.person = person;
//         this.address = address;
//         this.occupation = occupation;
//         this.salary = salary;
//         this.loanAmount = loadAmount;
//     }
// 
//     public LoanApplication() {
//     }
// 
//     public Person getPerson() {
//         return person;
//     }
// 
//     public void setPerson(Person person) {
//         this.person = person;
//     }
// 
//     public Address getAddress() {
//         return address;
//     }
// 
//     public void setAddress(Address address) {
//         this.address = address;
//     }
// 
//     public String getOccupation() {
//         return occupation;
//     }
// 
//     public void setOccupation(String occupation) {
//         this.occupation = occupation;
//     }
// 
//     public int getSalary() {
//         return salary;
//     }
// 
//     public void setSalary(int salary) {
//         this.salary = salary;
//     }
// 
//     public int getLoanAmount() {
//         return loanAmount;
//     }
// 
//     public void setLoanAmount(int loanAmount) {
//         this.loanAmount = loanAmount;
//     }
// 
// }


import com.github.ehe.simpleorchestrator.exception.OrchestratorException;
import com.github.ehe.simpleorchestrator.sample.context.AsyncCheckRiskContext;
import com.github.ehe.simpleorchestrator.sample.context.CreditScoreContext;
import com.github.ehe.simpleorchestrator.sample.context.LoanContext;
import com.github.ehe.simpleorchestrator.sample.context.ValidationContext;
import com.github.ehe.simpleorchestrator.sample.entity.LoanApplication;
import java.util.List;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.stream.Collectors;
/*
 *
 *  * Copyright (c) 2017. Eric He (eriche39@gmail.com)
 *  *
 *  * This software is licensed under
 *  *
 *  * MIT license
 *  *
 *
 */

package com.github.ehe.simpleorchestrator.sample.api.loan;



public class LoanOrchestratorContext implements CreditScoreContext, AsyncCheckRiskContext, LoanContext, ValidationContext<LoanApplication> {
    private LoanApplication application;
    private int creditScore;
    private boolean isApproved;
    private ConcurrentLinkedQueue<String> history = new ConcurrentLinkedQueue<>();
    private Future<Integer> riskScore;

    public void init(LoanApplication application){
        this.application = application;
    }

    @Override
    public String getSsn() {
        return application.getPerson().getSsn();
    }

    @Override
    public void setRiskScore(Future<Integer> score) {
// Path: core/src/main/java/com/github/ehe/simpleorchestrator/exception/OrchestratorException.java
// public class OrchestratorException extends RuntimeException {
// 
//     private static final long serialVersionUID = 1L;
// 
//     private int errorCode = 0;
// 
//     public OrchestratorException(String msg, Throwable cause) {
//         super(msg, cause);
//     }
// 
//     public OrchestratorException(String msg, int errorCode) {
//         super(msg);
//         this.errorCode = errorCode;
//     }
// 
//     public OrchestratorException(String msg, int errorCode, Throwable cause) {
//         super(msg, cause);
//         this.errorCode = errorCode;
//     }
// 
//     public int getErrorCode() {
//         return errorCode;
//     }
// }
// 
// Path: samples/src/main/java/com/github/ehe/simpleorchestrator/sample/context/AsyncCheckRiskContext.java
// public interface AsyncCheckRiskContext extends HistoryContext<String> {
//     String getSsn();
//     void setRiskScore(Future<Integer> score);
// }
// 
// Path: samples/src/main/java/com/github/ehe/simpleorchestrator/sample/context/CreditScoreContext.java
// public interface CreditScoreContext extends HistoryContext<String> {
//     String getSsn();
//     void setCreditScore(int score);
// }
// 
// Path: samples/src/main/java/com/github/ehe/simpleorchestrator/sample/context/LoanContext.java
// public interface LoanContext extends HistoryContext<String> {
//     LoanApplication getApplication();
//     int getCreditScore();
//     int getRiskScore();
//     void setLoanApproveStatus(boolean isApproved);
// }
// 
// Path: samples/src/main/java/com/github/ehe/simpleorchestrator/sample/context/ValidationContext.java
// public interface ValidationContext<A> extends HistoryContext<String> {
//     A getApplication();
// }
// 
// Path: samples/src/main/java/com/github/ehe/simpleorchestrator/sample/entity/LoanApplication.java
// public class LoanApplication {
// 
//     @NotNull
//     @Valid
//     private Person person;
// 
//     @Valid
//     private Address address;
// 
//     private String occupation;
// 
//     private int salary;
// 
//     private int loanAmount;
// 
//     public LoanApplication(Person person, Address address, String occupation, int salary, int loadAmount) {
//         this.person = person;
//         this.address = address;
//         this.occupation = occupation;
//         this.salary = salary;
//         this.loanAmount = loadAmount;
//     }
// 
//     public LoanApplication() {
//     }
// 
//     public Person getPerson() {
//         return person;
//     }
// 
//     public void setPerson(Person person) {
//         this.person = person;
//     }
// 
//     public Address getAddress() {
//         return address;
//     }
// 
//     public void setAddress(Address address) {
//         this.address = address;
//     }
// 
//     public String getOccupation() {
//         return occupation;
//     }
// 
//     public void setOccupation(String occupation) {
//         this.occupation = occupation;
//     }
// 
//     public int getSalary() {
//         return salary;
//     }
// 
//     public void setSalary(int salary) {
//         this.salary = salary;
//     }
// 
//     public int getLoanAmount() {
//         return loanAmount;
//     }
// 
//     public void setLoanAmount(int loanAmount) {
//         this.loanAmount = loanAmount;
//     }
// 
// }


// Path: samples/src/main/java/com/github/ehe/simpleorchestrator/sample/api/loan/LoanOrchestratorContext.java
import com.github.ehe.simpleorchestrator.exception.OrchestratorException;
import com.github.ehe.simpleorchestrator.sample.context.AsyncCheckRiskContext;
import com.github.ehe.simpleorchestrator.sample.context.CreditScoreContext;
import com.github.ehe.simpleorchestrator.sample.context.LoanContext;
import com.github.ehe.simpleorchestrator.sample.context.ValidationContext;
import com.github.ehe.simpleorchestrator.sample.entity.LoanApplication;
import java.util.List;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.stream.Collectors;

/*
 *
 *  * Copyright (c) 2017. Eric He (eriche39@gmail.com)
 *  *
 *  * This software is licensed under
 *  *
 *  * MIT license
 *  *
 *
 */

package com.github.ehe.simpleorchestrator.sample.api.loan;



public class LoanOrchestratorContext implements CreditScoreContext, AsyncCheckRiskContext, LoanContext, ValidationContext<LoanApplication> {
    private LoanApplication application;
    private int creditScore;
    private boolean isApproved;
    private ConcurrentLinkedQueue<String> history = new ConcurrentLinkedQueue<>();
    private Future<Integer> riskScore;

    public void init(LoanApplication application){
        this.application = application;
    }

    @Override
    public String getSsn() {
        return application.getPerson().getSsn();
    }

    @Override
    public void setRiskScore(Future<Integer> score) {
        this.riskScore = score;