// Path: src/main/java/com/github/fzakaria/waterflow/TaskType.java
// public enum TaskType {
//     ACTIVITY,
//     TIMER,
//     START_CHILD_WORKFLOW,
//     RECORD_MARKER,
//     SIGNAL_EXTERNAL_WORKFLOW,
//     CANCEL_EXTERNAL_WORKFLOW,
//     CONTINUE_AS_NEW,
//     DECISION,
//     WORKFLOW_EXECUTION,
//     WORKFLOW_SIGNALED
// }
// 
// Path: src/main/java/com/github/fzakaria/waterflow/TaskType.java
// public enum TaskType {
//     ACTIVITY,
//     TIMER,
//     START_CHILD_WORKFLOW,
//     RECORD_MARKER,
//     SIGNAL_EXTERNAL_WORKFLOW,
//     CANCEL_EXTERNAL_WORKFLOW,
//     CONTINUE_AS_NEW,
//     DECISION,
//     WORKFLOW_EXECUTION,
//     WORKFLOW_SIGNALED
// }
// 
// Path: src/main/java/com/github/fzakaria/waterflow/event/EventState.java
// public enum EventState {
// 
//     /**
//      * No events exist for the task.
//      */
//     NOT_STARTED,
// 
//     /**
//      * Initial event that started a task.
//      */
//     INITIAL,
// 
//     /**
//      * Event representing an ongoing task.
//      */
//     ACTIVE,
// 
//     /**
//      * Event representing a task that needs to be retried.
//      */
//     RETRY,
// 
//     /**
//      * Event representing a task that has completed successfully.
//      */
//     SUCCESS,
// 
//     /**
//      * Event representing a task that has failed.
//      */
//     ERROR
// }


import com.amazonaws.services.simpleworkflow.model.EventType;
import com.amazonaws.services.simpleworkflow.model.HistoryEvent;
import com.github.fzakaria.waterflow.TaskType;
import com.github.fzakaria.waterflow.immutable.ActionId;
import org.immutables.value.Value;
import java.time.Instant;
import java.util.List;
import java.util.Optional;
import static com.amazonaws.services.simpleworkflow.model.EventType.*;
import static com.github.fzakaria.waterflow.TaskType.*;
import static com.github.fzakaria.waterflow.event.EventState.*;
import static java.lang.String.format;
import static java.util.stream.Collectors.toList;
        if (ActivityTaskFailed == type()) { return ACTIVITY; }
        if (ActivityTaskTimedOut == type()) { return ACTIVITY; }
        if (ActivityTaskCanceled == type()) { return ACTIVITY; }
        if (ActivityTaskCancelRequested == type()) { return ACTIVITY; }
        if (RequestCancelActivityTaskFailed == type()) { return ACTIVITY; }
        if (WorkflowExecutionSignaled == type()) { return WORKFLOW_SIGNALED; }
        if (MarkerRecorded == type()) { return RECORD_MARKER; }
        if (RecordMarkerFailed == type()) { return RECORD_MARKER; }
        if (TimerStarted == type()) { return TIMER; }
        if (StartTimerFailed == type()) { return TIMER; }
        if (TimerFired == type()) { return TIMER; }
        if (TimerCanceled == type()) { return TIMER; }
        if (CancelTimerFailed == type()) { return TIMER; }
        if (StartChildWorkflowExecutionInitiated == type()) { return START_CHILD_WORKFLOW; }
        if (StartChildWorkflowExecutionFailed == type()) { return START_CHILD_WORKFLOW; }
        if (ChildWorkflowExecutionStarted == type()) { return START_CHILD_WORKFLOW; }
        if (ChildWorkflowExecutionCompleted == type()) { return START_CHILD_WORKFLOW; }
        if (ChildWorkflowExecutionFailed == type()) { return START_CHILD_WORKFLOW; }
        if (ChildWorkflowExecutionTimedOut == type()) { return START_CHILD_WORKFLOW; }
        if (ChildWorkflowExecutionCanceled == type()) { return START_CHILD_WORKFLOW; }
        if (ChildWorkflowExecutionTerminated == type()) { return START_CHILD_WORKFLOW; }
        if (SignalExternalWorkflowExecutionInitiated == type()) { return SIGNAL_EXTERNAL_WORKFLOW; }
        if (SignalExternalWorkflowExecutionFailed == type()) { return SIGNAL_EXTERNAL_WORKFLOW; }
        if (ExternalWorkflowExecutionSignaled == type()) { return SIGNAL_EXTERNAL_WORKFLOW; }
        if (RequestCancelExternalWorkflowExecutionInitiated == type()) { return CANCEL_EXTERNAL_WORKFLOW; }
        if (RequestCancelExternalWorkflowExecutionFailed == type()) { return CANCEL_EXTERNAL_WORKFLOW; }
        if (ExternalWorkflowExecutionCancelRequested == type()) { return CANCEL_EXTERNAL_WORKFLOW; }
        throw new IllegalArgumentException("Unknown EventType " + type());
    }

// Path: src/main/java/com/github/fzakaria/waterflow/TaskType.java
// public enum TaskType {
//     ACTIVITY,
//     TIMER,
//     START_CHILD_WORKFLOW,
//     RECORD_MARKER,
//     SIGNAL_EXTERNAL_WORKFLOW,
//     CANCEL_EXTERNAL_WORKFLOW,
//     CONTINUE_AS_NEW,
//     DECISION,
//     WORKFLOW_EXECUTION,
//     WORKFLOW_SIGNALED
// }
// 
// Path: src/main/java/com/github/fzakaria/waterflow/TaskType.java
// public enum TaskType {
//     ACTIVITY,
//     TIMER,
//     START_CHILD_WORKFLOW,
//     RECORD_MARKER,
//     SIGNAL_EXTERNAL_WORKFLOW,
//     CANCEL_EXTERNAL_WORKFLOW,
//     CONTINUE_AS_NEW,
//     DECISION,
//     WORKFLOW_EXECUTION,
//     WORKFLOW_SIGNALED
// }
// 
// Path: src/main/java/com/github/fzakaria/waterflow/event/EventState.java
// public enum EventState {
// 
//     /**
//      * No events exist for the task.
//      */
//     NOT_STARTED,
// 
//     /**
//      * Initial event that started a task.
//      */
//     INITIAL,
// 
//     /**
//      * Event representing an ongoing task.
//      */
//     ACTIVE,
// 
//     /**
//      * Event representing a task that needs to be retried.
//      */
//     RETRY,
// 
//     /**
//      * Event representing a task that has completed successfully.
//      */
//     SUCCESS,
// 
//     /**
//      * Event representing a task that has failed.
//      */
//     ERROR
// }


// Path: src/main/java/com/github/fzakaria/waterflow/event/Event.java
import com.amazonaws.services.simpleworkflow.model.EventType;
import com.amazonaws.services.simpleworkflow.model.HistoryEvent;
import com.github.fzakaria.waterflow.TaskType;
import com.github.fzakaria.waterflow.immutable.ActionId;
import org.immutables.value.Value;
import java.time.Instant;
import java.util.List;
import java.util.Optional;
import static com.amazonaws.services.simpleworkflow.model.EventType.*;
import static com.github.fzakaria.waterflow.TaskType.*;
import static com.github.fzakaria.waterflow.event.EventState.*;
import static java.lang.String.format;
import static java.util.stream.Collectors.toList;

        if (ActivityTaskFailed == type()) { return ACTIVITY; }
        if (ActivityTaskTimedOut == type()) { return ACTIVITY; }
        if (ActivityTaskCanceled == type()) { return ACTIVITY; }
        if (ActivityTaskCancelRequested == type()) { return ACTIVITY; }
        if (RequestCancelActivityTaskFailed == type()) { return ACTIVITY; }
        if (WorkflowExecutionSignaled == type()) { return WORKFLOW_SIGNALED; }
        if (MarkerRecorded == type()) { return RECORD_MARKER; }
        if (RecordMarkerFailed == type()) { return RECORD_MARKER; }
        if (TimerStarted == type()) { return TIMER; }
        if (StartTimerFailed == type()) { return TIMER; }
        if (TimerFired == type()) { return TIMER; }
        if (TimerCanceled == type()) { return TIMER; }
        if (CancelTimerFailed == type()) { return TIMER; }
        if (StartChildWorkflowExecutionInitiated == type()) { return START_CHILD_WORKFLOW; }
        if (StartChildWorkflowExecutionFailed == type()) { return START_CHILD_WORKFLOW; }
        if (ChildWorkflowExecutionStarted == type()) { return START_CHILD_WORKFLOW; }
        if (ChildWorkflowExecutionCompleted == type()) { return START_CHILD_WORKFLOW; }
        if (ChildWorkflowExecutionFailed == type()) { return START_CHILD_WORKFLOW; }
        if (ChildWorkflowExecutionTimedOut == type()) { return START_CHILD_WORKFLOW; }
        if (ChildWorkflowExecutionCanceled == type()) { return START_CHILD_WORKFLOW; }
        if (ChildWorkflowExecutionTerminated == type()) { return START_CHILD_WORKFLOW; }
        if (SignalExternalWorkflowExecutionInitiated == type()) { return SIGNAL_EXTERNAL_WORKFLOW; }
        if (SignalExternalWorkflowExecutionFailed == type()) { return SIGNAL_EXTERNAL_WORKFLOW; }
        if (ExternalWorkflowExecutionSignaled == type()) { return SIGNAL_EXTERNAL_WORKFLOW; }
        if (RequestCancelExternalWorkflowExecutionInitiated == type()) { return CANCEL_EXTERNAL_WORKFLOW; }
        if (RequestCancelExternalWorkflowExecutionFailed == type()) { return CANCEL_EXTERNAL_WORKFLOW; }
        if (ExternalWorkflowExecutionCancelRequested == type()) { return CANCEL_EXTERNAL_WORKFLOW; }
        throw new IllegalArgumentException("Unknown EventType " + type());
    }

    public EventState state() {