question: protected < T extends TaskServiceDocument < E > , E extends Enum < E > > T waitForTaskCompletion ( String documentSelfLink , Class < T > type ) throws Throwable { return waitForPropertyValue ( documentSelfLink , type , TaskServiceDocument . FIELD_NAME_TASK_STAGE , Arrays . asList ( TaskStage . FINISHED , TaskStage . FAILED , TaskStage . CANCELLED ) , true , waitForStageChangeCountLonger ( ) ) ; }
target:  Waits until the given task completes and returns its final state.