code: public void restoreState(FacesContext context, Object state) {
  
          if (context == null) {
              throw new NullPointerException();
          }
          if (state == null) {
              return;
          }
          
          if (!component.initialStateMarked() && !defaultMap.isEmpty())
          {
              defaultMap.clear();
              if(deltaMap != null && !deltaMap.isEmpty())
              {
                  deltaMap.clear();
              }
          }
          
          Object[] savedState = (Object[]) state;
          if (savedState[savedState.length - 1] != null) {
              component.initialState = (Boolean) savedState[savedState.length - 1];
          }
          int length = (savedState.length-1)/2;
          for (int i = 0; i < length; i++) {
             Object value = savedState[i * 2 + 1];
              Serializable serializable = (Serializable) savedState[i * 2];
              if (value != null) {
                  if (value instanceof Collection) {
                      value = restoreAttachedState(context, value);
                  } else if (value instanceof StateHolderSaver) {
                      value = ((StateHolderSaver) value).restore(context);
                  } else {
                      value = (value instanceof Serializable
                               ? value
                               : restoreAttachedState(context, value));
                  }
              }
              if (value instanceof Map) {
                  for (Map.Entry<String, Object> entry : ((Map<String, Object>) value)
                        .entrySet()) {
                      this.put(serializable, entry.getKey(), entry.getValue());
                  }
              } else if (value instanceof List) {
                  List<Object> list = (List) get(serializable);
                  for (Object o : ((List<Object>) value)) {
                      if (list == null || !list.contains(o)) {
                          this.add(serializable, o);
                      }
                  }
              } else {
                  put(serializable, value);
              }
          }
      }
docs: One and only implementation of
  restore state. Makes all other implementations
  unnecessary.
  
  @param context FacesContext
  @param state the state to be restored.