code: public static State getReefTaskState(final CloudTask task) {
      switch (task.state()) {
      case ACTIVE:
        return State.INIT;
      case RUNNING:
        return State.RUNNING;
      case COMPLETED:
        if (task.executionInfo().result() == TaskExecutionResult.SUCCESS) {
          return State.DONE;
        } else {
          return State.FAILED;
        }
      case PREPARING:
        return State.RUNNING;
      default:
        throw new IllegalArgumentException("Azure batch cloud task has unknown state: " + task.state());
      }
    }
docs: Get the {@link State} from a {@link CloudTask}.
  
  @param task the task.
  @return the state of the task.