private <T>void registerModification(PropertyDefinition<T> pd,SortedSet<T> newValues,SortedSet<T> previousValues){
  if (isLastChoiceReset) {
    registerResetModification(pd,previousValues);
  }
 else   if (!newValues.equals(previousValues)) {
    if (newValues.containsAll(previousValues)) {
      if (newValues.size() <= 1) {
        registerSetModification(pd,newValues,previousValues);
      }
 else {
        registerAddModification(pd,newValues,previousValues);
      }
    }
 else     if (previousValues.containsAll(newValues)) {
      registerRemoveModification(pd,newValues,previousValues);
    }
 else     if (newValues.size() <= 1) {
      registerSetModification(pd,newValues,previousValues);
    }
 else {
      SortedSet<T> removedValues=new TreeSet<>(previousValues);
      removedValues.removeAll(newValues);
      PropertyEditorModification<T> removeMod=PropertyEditorModification.createRemoveModification(pd,removedValues,previousValues);
      addModification(removeMod);
      SortedSet<T> retainedValues=new TreeSet<>(previousValues);
      retainedValues.retainAll(newValues);
      SortedSet<T> addedValues=new TreeSet<>(newValues);
      addedValues.removeAll(retainedValues);
      PropertyEditorModification<T> addMod=PropertyEditorModification.createAddModification(pd,addedValues,retainedValues);
      addModification(addMod);
    }
  }
}

private < T > void registerModification ( PropertyDefinition < T > pd , SortedSet < T > newValues , SortedSet < T > previousValues ) { if ( isLastChoiceReset ) { registerResetModification ( pd , previousValues ) ; } else if ( ! newValues . equals ( previousValues ) ) { if ( newValues . containsAll ( previousValues ) ) { if ( newValues . size ( ) <= 1 ) { registerSetModification ( pd , newValues , previousValues ) ; } else { registerAddModification ( pd , newValues , previousValues ) ; } } else if ( previousValues . containsAll ( newValues ) ) { registerRemoveModification ( pd , newValues , previousValues ) ; } else if ( newValues . size ( ) <= 1 ) { registerSetModification ( pd , newValues , previousValues ) ; } else { SortedSet < T > removedValues = new TreeSet < > ( previousValues ) ; removedValues . removeAll ( newValues ) ; PropertyEditorModification < T > removeMod = PropertyEditorModification . createRemoveModification ( pd , removedValues , previousValues ) ; addModification ( removeMod ) ; SortedSet < T > retainedValues = new TreeSet < > ( previousValues ) ; retainedValues . retainAll ( newValues ) ; SortedSet < T > addedValues = new TreeSet < > ( newValues ) ; addedValues . removeAll ( retainedValues ) ; PropertyEditorModification < T > addMod = PropertyEditorModification . createAddModification ( pd , addedValues , retainedValues ) ; addModification ( addMod ) ; } } }
register the modification in the list of modifications .
