code: @Override
      public void save(final SagaState state) {
          checkNotNull(state, "State not allowed to be null.");
          checkNotNull(state.getSagaId(), "State saga id not allowed to be null.");
          checkNotNull(state.getType(), "Saga type must not be null.");
  
          synchronized (sync) {
              String sagaId = state.getSagaId();
  
              StateStorageItem stateStorageItem = storedStates.get(sagaId);
              if (stateStorageItem == null) {
                  stateStorageItem = StateStorageItem.withCurrentInstanceKeys(state);
                  storedStates.put(state.getSagaId(), stateStorageItem);
              } else {
                  // remove previous stored keys from map
                  // some entries may have been removed from the state during
                  // saga execution
                  removeInstancesForItem(stateStorageItem);
  
                  // once old values have been removed update item with current
                  // values
                  stateStorageItem.updateInstanceKeys();
              }
  
              for (SagaMultiKey key : stateStorageItem.instanceKeys()) {
                  instanceKeyMap.put(key, state);
              }
          }
      }
docs: {@inheritDoc}