List changes = getFeatureChanges(eObject); FeatureChange change = getFeatureChange(changes, feature);
List changes = null; FeatureChange change = null; if (isRecording()) { changes = getFeatureChanges(eObject); change = getFeatureChange(changes, feature); }
  protected void handleFeature(EStructuralFeature feature, EReference containment, Notification notification, EObject eObject)  {    // EATM This is a hack.     // Since we can't record these changes properly, it's best not to record them at all.    //    if (FeatureMapUtil.isFeatureMap(feature))    {      return;    }        List changes = getFeatureChanges(eObject);    FeatureChange change = getFeatureChange(changes, feature);    int event = notification.getEventType();    switch (event)    {      case Notification.SET:      case Notification.UNSET:      {        if (change == null && isRecording())        {          if (feature.isMany())          {            List oldValue = new BasicEList((Collection)eObject.eGet(feature));            int index = notification.getPosition();            if (index != Notification.NO_INDEX)            {              oldValue.set(index, notification.getOldValue());            }            change = createFeatureChange(eObject, feature, oldValue, notification.wasSet());          }          else          {            Object oldValue = notification.getOldValue();            change = createFeatureChange(eObject, feature, oldValue, notification.wasSet());          }          ((InternalEList)changes).addUnique(change);        }        if (containment != null)        {          Notifier newValue = (Notifier)notification.getNewValue();          if (newValue != null)          {            addAdapter(newValue);          }        }        break;      }      case Notification.ADD:      {        if (change == null && isRecording())        {          List oldValue = new BasicEList((Collection)eObject.eGet(feature));          oldValue.remove(notification.getPosition());          change = createFeatureChange(eObject, feature, oldValue, notification.wasSet());          ((InternalEList)changes).addUnique(change);        }        if (containment != null)        {          Notifier newValue = (Notifier)notification.getNewValue();          addAdapter(newValue);        }        break;      }      case Notification.ADD_MANY:      {        if (change == null && isRecording())        {          List oldValue = new BasicEList((Collection)eObject.eGet(feature));          int position = notification.getPosition();          for (int i = ((Collection)notification.getNewValue()).size(); --i >= 0;)          {            oldValue.remove(position);          }          change = createFeatureChange(eObject, feature, oldValue, notification.wasSet());          ((InternalEList)changes).addUnique(change);        }        if (containment != null)        {          Collection newValues = (Collection)notification.getNewValue();          for (Iterator i = newValues.iterator(); i.hasNext();)          {            Notifier newValue = (Notifier)i.next();            addAdapter(newValue);          }        }        break;      }      case Notification.REMOVE:      {        if (change == null && isRecording())        {          List oldValue = new BasicEList((Collection)eObject.eGet(feature));          // If there's no position, the list is being cleared.          //          int position = notification.getPosition();          if (position == Notification.NO_INDEX)          {            position = 0;          }          oldValue.add(position, notification.getOldValue());          change = createFeatureChange(eObject, feature, oldValue, notification.wasSet());          ((InternalEList)changes).addUnique(change);        }        break;      }      case Notification.REMOVE_MANY:      {        if (change == null && isRecording())        {          List removedValues = (List)notification.getOldValue();          List oldValue = new BasicEList((Collection)eObject.eGet(feature));          int[] positions = (int[])notification.getNewValue();          if (positions == null)          {            oldValue.addAll(removedValues);          }          else          {            for (int i = 0; i < positions.length; ++i)            {              oldValue.add(positions[i], removedValues.get(i));            }          }          change = createFeatureChange(eObject, feature, oldValue, notification.wasSet());          ((InternalEList)changes).addUnique(change);        }        break;      }      case Notification.MOVE:      {        if (change == null && isRecording())        {          EList oldValue = new BasicEList((Collection)eObject.eGet(feature));          int position = notification.getPosition();          int oldPosition = ((Integer)notification.getOldValue()).intValue();          oldValue.move(oldPosition, position);          change = createFeatureChange(eObject, feature, oldValue, notification.wasSet());          ((InternalEList)changes).addUnique(change);        }        break;      }    }  }