package com.hubspot.singularity;

import com.google.common.base.Optional;
import com.hubspot.mesos.protos.MesosTaskState;

import io.swagger.v3.oas.annotations.media.Schema;

@Schema
public enum ExtendedTaskState {
  TASK_LAUNCHED("launched", false, Optional.absent()), 
  TASK_STAGING("staging", false, Optional.of(MesosTaskState.TASK_STAGING)),
  TASK_STARTING("starting", false, Optional.of(MesosTaskState.TASK_STARTING)), 
  TASK_RUNNING("running", false, Optional.of(MesosTaskState.TASK_RUNNING)),
  TASK_CLEANING("cleaning", false, Optional.absent()), 
  TASK_KILLING("killing", false, Optional.of(MesosTaskState.TASK_KILLING)), 
  TASK_FINISHED("finished", true, Optional.of(MesosTaskState.TASK_FINISHED)),
  TASK_FAILED("failed", true, Optional.of(MesosTaskState.TASK_FAILED)), 
  TASK_KILLED("killed", true, Optional.of(MesosTaskState.TASK_KILLED)),
  TASK_LOST("lost", true, Optional.of(MesosTaskState.TASK_LOST)), 
  TASK_LOST_WHILE_DOWN("lost", true, Optional.absent()), 
  TASK_ERROR("error", true, Optional.of(MesosTaskState.TASK_ERROR)),
  TASK_DROPPED("dropped", true, Optional.of(MesosTaskState.TASK_DROPPED)), 
  TASK_GONE("gone", true, Optional.of(MesosTaskState.TASK_GONE)), 
  TASK_UNREACHABLE("unreachable", true, Optional.of(MesosTaskState.TASK_UNREACHABLE)),
  TASK_GONE_BY_OPERATOR("goneByOperator", true, Optional.of(MesosTaskState.TASK_GONE_BY_OPERATOR)), 
  TASK_UNKNOWN("dropped", true, Optional.of(MesosTaskState.TASK_UNKNOWN));

  private final String displayName;
  private final boolean isDone;
  private final Optional<MesosTaskState> taskState;

  ExtendedTaskState(String displayName, boolean isDone, Optional<MesosTaskState> taskState) {
    this.displayName = displayName;
    this.isDone = isDone;
    this.taskState = taskState;
  }

  public String getDisplayName() {
    return displayName;
  }

  public boolean isDone() {
    return isDone;
  }

  public boolean isFailed() {
    return this == TASK_FAILED;
  }

  public boolean isSuccess() {
    return this == TASK_FINISHED;
  }

  public Optional<MesosTaskState> toTaskState() {
    return taskState;
  }
}

@@ -254,33 +254,32 @@
 ional.absent()),
- 
 %0A  TASK_STAGING(
@@ -413,25 +413,24 @@
 _STARTING)),
- 
 %0A  TASK_RUNN
@@ -540,33 +540,32 @@
 ional.absent()),
- 
 %0A  TASK_KILLING(
@@ -624,17 +624,16 @@
 LLING)),
- 
 %0A  TASK_
@@ -770,25 +770,24 @@
 SK_FAILED)),
- 
 %0A  TASK_KILL
@@ -912,17 +912,16 @@
 _LOST)),
- 
 %0A  TASK_
@@ -969,17 +969,16 @@
 sent()),
- 
 %0A  TASK_
@@ -1113,17 +1113,16 @@
 OPPED)),
- 
 %0A  TASK_
@@ -1179,17 +1179,16 @@
 _GONE)),
- 
 %0A  TASK_
@@ -1366,17 +1366,16 @@
 RATOR)),
- 
 %0A  TASK_

remove trailing spaces