Source:
private void handleFilteredNotification(Notification notification) { Object notifier = notification.getNotifier(); Element baseElement = null; Element extendedElement = null; Stereotype stereotype = null; if (notifier instanceof EObject) { stereotype = finder.getDefiningStereotype((EObject) notifier); if (stereotype != null) { extendedElement = finder.getExtendedElement((EObject) notifier); } boolean isBaseFeature = ((EStructuralFeature) notification.getFeature()).getName().startsWith(Extension.METACLASS_ROLE_PREFIX); if (!isBaseFeature) { baseElement = StereotypeExtensionFinder.getBaseElement((EObject) notifier); } } int eventType = 0; if (stereotype != null) { if (baseElement != null) { eventType = StereotypeExtensionNotification.MODIFIED_STEREOTYPE_TO_ELEMENT; } else if (extendedElement == null) { extendedElement = (Element) notification.getOldValue(); eventType = StereotypeExtensionNotification.STEREOTYPE_UNAPPLIED_FROM_ELEMENT; } else { extendedElement = (Element) notification.getNewValue(); eventType = StereotypeExtensionNotification.STEREOTYPE_APPLIED_TO_ELEMENT; } } if (stereotype != null) { EObject oldValue = null; EObject newValue = null; Element element = extendedElement; switch (eventType) { case StereotypeExtensionNotification.STEREOTYPE_UNAPPLIED_FROM_ELEMENT: oldValue = stereotype; break; case StereotypeExtensionNotification.STEREOTYPE_APPLIED_TO_ELEMENT: newValue = stereotype; break; case StereotypeExtensionNotification.MODIFIED_STEREOTYPE_TO_ELEMENT: newValue = baseElement; element = baseElement; break; default: } element.eNotify( new StereotypeExtensionNotification(element, eventType, oldValue, newValue)); } }

Target:
private void handleFilteredNotification(Notification notification) { Object notifier = notification.getNotifier(); Element extendedElement = null; Stereotype stereotype = null; boolean isBaseFeature = true; if (notifier instanceof EObject) { stereotype = finder.getDefiningStereotype((EObject) notifier); if (stereotype != null) { extendedElement = finder.getExtendedElement((EObject) notifier); isBaseFeature = ((EStructuralFeature) notification.getFeature()).getName().startsWith(Extension.METACLASS_ROLE_PREFIX); } } int eventType = 0; if (stereotype != null) { if (!isBaseFeature) { eventType = StereotypeExtensionNotification.MODIFIED_STEREOTYPE_OF_ELEMENT; } else if (extendedElement == null) { extendedElement = (Element) notification.getOldValue(); eventType = StereotypeExtensionNotification.STEREOTYPE_UNAPPLIED_FROM_ELEMENT; } else { extendedElement = (Element) notification.getNewValue(); eventType = StereotypeExtensionNotification.STEREOTYPE_APPLIED_TO_ELEMENT; } } if (stereotype != null) { EObject oldValue = null; Object newValue = null; Element element = extendedElement; switch (eventType) { case StereotypeExtensionNotification.STEREOTYPE_UNAPPLIED_FROM_ELEMENT: oldValue = stereotype; break; case StereotypeExtensionNotification.STEREOTYPE_APPLIED_TO_ELEMENT: newValue = stereotype; break; case StereotypeExtensionNotification.MODIFIED_STEREOTYPE_OF_ELEMENT: newValue = notification.getNewValue(); break; default: } element.eNotify( new StereotypeExtensionNotification(element, eventType, oldValue, newValue)); } }