public <T>CompletableFuture<T> apply(long index){
  if (index > lastApplied + 1) {
    applyAll(index - 1);
  }
  try (Entry entry=log.get(index)){
    if (entry != null) {
      return apply(entry);
    }
 else {
      return CompletableFuture.completedFuture(null);
    }
  }
  finally {
    setLastApplied(index);
  }
}

public < T > CompletableFuture < T > apply ( long index ) { if ( index > lastApplied + 1 ) { applyAll ( index - 1 ) ; } try ( Entry entry = log . get ( index ) ) { if ( entry != null ) { return apply ( entry ) ; } else { return CompletableFuture . completedFuture ( null ) ; } } finally { setLastApplied ( index ) ; } }
applies the entry at the given index to the state machine . < p > calls to this method are assumed to expect a result . this means linearizable session events triggered by the application of the command at the given index will be awaited before completing the returned future .
