private <T>void registerRemoveModification(PropertyDefinition<T> pd,SortedSet<T> newValues,SortedSet<T> previousValues){
  PropertyEditorModification<?> mod=getModification(pd);
  PropertyEditorModification<T> newMod;
  SortedSet<T> originalValues;
  if (mod != null) {
    originalValues=new TreeSet<>(pd);
    castAndAddValues(originalValues,mod.getOriginalValues(),pd);
    if (newValues.isEmpty()) {
      newMod=PropertyEditorModification.createRemoveModification(pd,originalValues,originalValues);
    }
 else     if (mod.getType() == PropertyEditorModification.Type.REMOVE) {
      SortedSet<T> removedValues=new TreeSet<>(originalValues);
      removedValues.removeAll(newValues);
      newMod=PropertyEditorModification.createRemoveModification(pd,removedValues,originalValues);
    }
 else {
      newMod=PropertyEditorModification.createSetModification(pd,new TreeSet<T>(newValues),originalValues);
    }
    removeModification(mod);
  }
 else {
    originalValues=new TreeSet<>(previousValues);
    SortedSet<T> removedValues=new TreeSet<>(originalValues);
    removedValues.removeAll(newValues);
    newMod=PropertyEditorModification.createRemoveModification(pd,removedValues,originalValues);
  }
  addModification(newMod);
}

private < T > void registerRemoveModification ( PropertyDefinition < T > pd , SortedSet < T > newValues , SortedSet < T > previousValues ) { PropertyEditorModification < ? > mod = getModification ( pd ) ; PropertyEditorModification < T > newMod ; SortedSet < T > originalValues ; if ( mod != null ) { originalValues = new TreeSet < > ( pd ) ; castAndAddValues ( originalValues , mod . getOriginalValues ( ) , pd ) ; if ( newValues . isEmpty ( ) ) { newMod = PropertyEditorModification . createRemoveModification ( pd , originalValues , originalValues ) ; } else if ( mod . getType ( ) == PropertyEditorModification . Type . REMOVE ) { SortedSet < T > removedValues = new TreeSet < > ( originalValues ) ; removedValues . removeAll ( newValues ) ; newMod = PropertyEditorModification . createRemoveModification ( pd , removedValues , originalValues ) ; } else { newMod = PropertyEditorModification . createSetModification ( pd , new TreeSet < T > ( newValues ) , originalValues ) ; } removeModification ( mod ) ; } else { originalValues = new TreeSet < > ( previousValues ) ; SortedSet < T > removedValues = new TreeSet < > ( originalValues ) ; removedValues . removeAll ( newValues ) ; newMod = PropertyEditorModification . createRemoveModification ( pd , removedValues , originalValues ) ; } addModification ( newMod ) ; }
register a remove modification in the list of modifications .
