private void handleRemoveNotification(NotificationInfo n) { // validation for REMOVE reference if (n.isReferenceNotification()) { // non model element references must be marked transient if (!(n.getOldValue() instanceof EObject)) { n.setValid(false); n.setValidationMessage( "Non-transient non-EObject reference feature detected: " + n.getNotifier().getClass().getCanonicalName() + "-" + n.getReference().getName()); return; } // checking up on EMF... if (!n.getReference().isMany()) { n.setValid(false); n.setValidationMessage( "Unkown notification state: REMOVE notification on reference " + "feature with isMany==false"); } } // no validation for REMOVE attribute }
private void handleSetNotification(NotificationInfo n) { // validation for SET reference if (n.isReferenceNotification()) { // sanity check newValue and oldValue must be ModelElements or null Object newValueObject = n.getNewValue(); Object oldValueObject = n.getOldValue(); boolean newValIsNoME = newValueObject != null && !(newValueObject instanceof EObject); boolean oldValIsNoME = oldValueObject != null && !(oldValueObject instanceof EObject); if (newValIsNoME || oldValIsNoME) { // non model element references must be marked transient n.setValid(false); n.setValidationMessage( "Non-transient non-EObject reference feature detected: " + n.getNotifier().getClass().getCanonicalName() + "-" + n.getReference().getName()); return; } } // no validation for SET attribute }
private void handleRemoveManyNotification(NotificationInfo n) { // // attributes not allowed for REMOVE_MANY (yet) // if (n.isAttributeNotification()) { // n.setValid(false); // n.setValidationMessage("REMOVE_MANY on attribute feature with multiplicity greater" // + "than 1 not yet supported."); // return; // } // reference validation if (n.isReferenceNotification()) { // the new guys must come in a list if (!(n.getOldValue() instanceof List<?>)) { n.setValid(false); n.setValidationMessage( "Non-List oldValue argument for REMOVE_MANY notification on: " + n.getNotifier().getClass().getCanonicalName() + "-" + n.getReference().getName()); return; } // checking up on EMF, the reference must have max multiplicity greater than 1... if (!n.getReference().isMany()) { n.setValid(false); n.setValidationMessage( "Unkown notification state: REMOVE_MANY notification on reference " + "feature with isMany==false"); return; } } }
private void handleMoveNotification(NotificationInfo n) { // if (n.isAttributeNotification()) { // n.setValid(false); // n.setValidationMessage("MOVE notification on attribute feature with multiplicty" // + "greater 1 not supported yet!"); // return; // } if (n.isReferenceNotification()) { // sanity checks if (n.getNewValue() == null || n.getOldValue() == null) { n.setValid(false); n.setValidationMessage( "Null detected in oldValue or NewValue of move notification about: " + n.getNotifier().getClass().getCanonicalName() + "-" + n.getReference().getName()); return; } if (!(n.getNewValue() instanceof EObject)) { // non model element references must be marked transient n.setValid(false); n.setValidationMessage( "Non-transient non-EObject reference feature detected: " + n.getNotifier().getClass().getCanonicalName() + "-" + n.getReference().getName()); return; } if (!(n.getOldValue() instanceof Integer)) { n.setValid(false); n.setValidationMessage("Error with old position in move: not an Integer"); return; } } }