@SuppressWarnings("unchecked")
 private void refreshDerivedFeature() {
   logger.trace("[Notify: " + derivedFeature.getName() + "] Derived refresh.");
   try {
     if (source.eNotificationRequired()) {
       if (type == null) {
         type = derivedFeature.getEType();
       }
       if (derivedFeature.isMany()) {
         if (currentValue != null) {
           oldValue = new HashSet<EObject>((Collection<EObject>) currentValue);
         } else {
           oldValue = new HashSet<EObject>();
         }
         currentValue = new HashSet<EObject>();
         Collection<? extends Object> targets =
             (Collection<? extends Object>) source.eGet(derivedFeature);
         int position = 0;
         for (Object target : targets) {
           comprehension.traverseFeature(visitor, source, derivedFeature, target, position++);
         }
         if (currentValue instanceof Collection<?> && oldValue instanceof Collection<?>) {
           ((Collection<?>) oldValue).removeAll((Collection<?>) currentValue);
           if (((Collection<?>) oldValue).size() > 0) {
             sendRemoveManyNotification(source, derivedFeature, oldValue);
           }
         }
       } else {
         Object target = source.eGet(derivedFeature);
         comprehension.traverseFeature(visitor, source, derivedFeature, target, null);
       }
     }
   } catch (Exception ex) {
     logger.error(
         "The derived feature adapter encountered an error in processing the EMF model. "
             + "This happened while maintaining the derived feature "
             + derivedFeature.getName()
             + " of object "
             + source,
         ex);
   }
 }
Esempio n. 2
0
 @Override
 protected boolean isNotificationRequired() {
   return owner.eNotificationRequired();
 }