@SuppressWarnings("unchecked")
  @Override
  public void reconstruct(RebindContext rebindContext, EntityMemento memento) {
    if (LOG.isTraceEnabled()) LOG.trace("Reconstructing entity: {}", memento.toVerboseString());

    // Note that the id should have been set in the constructor; it is immutable
    entity.setDisplayName(memento.getDisplayName());

    for (Effector<?> eff : memento.getEffectors())
      ((EntityInternal) entity).getMutableEntityType().addEffector(eff);

    for (Map.Entry<ConfigKey<?>, Object> entry : memento.getConfig().entrySet()) {
      try {
        ConfigKey<?> key = entry.getKey();
        Object value = entry.getValue();
        Class<?> type =
            (key.getType() != null) ? key.getType() : rebindContext.loadClass(key.getTypeName());
        entity.setConfig((ConfigKey<Object>) key, value);
      } catch (ClassNotFoundException e) {
        throw Throwables.propagate(e);
      }
    }

    ((EntityInternal) entity).getConfigMap().addToLocalBag(memento.getConfigUnmatched());
    ((EntityInternal) entity).refreshInheritedConfig();

    for (Map.Entry<AttributeSensor<?>, Object> entry : memento.getAttributes().entrySet()) {
      try {
        AttributeSensor<?> key = entry.getKey();
        Object value = entry.getValue();
        Class<?> type =
            (key.getType() != null) ? key.getType() : rebindContext.loadClass(key.getTypeName());
        ((EntityInternal) entity)
            .setAttributeWithoutPublishing((AttributeSensor<Object>) key, value);
      } catch (ClassNotFoundException e) {
        throw Throwables.propagate(e);
      }
    }

    setParent(rebindContext, memento);
    addChildren(rebindContext, memento);
    addPolicies(rebindContext, memento);
    addEnrichers(rebindContext, memento);
    addMembers(rebindContext, memento);
    addTags(rebindContext, memento);
    addLocations(rebindContext, memento);

    doReconstruct(rebindContext, memento);
    ((AbstractEntity) entity).rebind();
  }