code: public CheckPointState nextState(boolean recovering) {
          CheckPointState nextState;
          switch (state) {
              case PREPARING:
                  nextState = recovering ? new CheckPointState(txid - 1, State.COMMITTED) : new CheckPointState(txid, State.COMMITTING);
                  break;
              case COMMITTING:
                  nextState = new CheckPointState(txid, State.COMMITTED);
                  break;
              case COMMITTED:
                  nextState = recovering ? this : new CheckPointState(txid + 1, State.PREPARING);
                  break;
              default:
                  throw new IllegalStateException("Unknown state " + state);
          }
          return nextState;
      }
docs: Get the next state based on this checkpoint state.
  
  @param recovering if in recovering phase
  @return the next checkpoint state based on this state.