private <T>void registerAddModification(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 (mod.getType() == PropertyEditorModification.Type.ADD) {
      SortedSet<T> addedValues=new TreeSet<>(newValues);
      addedValues.removeAll(originalValues);
      newMod=PropertyEditorModification.createAddModification(pd,addedValues,originalValues);
    }
 else {
      newMod=PropertyEditorModification.createSetModification(pd,new TreeSet<T>(newValues),originalValues);
    }
    removeModification(mod);
  }
 else {
    originalValues=new TreeSet<>(previousValues);
    SortedSet<T> addedValues=new TreeSet<>(newValues);
    addedValues.removeAll(originalValues);
    newMod=PropertyEditorModification.createAddModification(pd,addedValues,originalValues);
  }
  addModification(newMod);
}

private < T > void registerAddModification ( 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 ( mod . getType ( ) == PropertyEditorModification . Type . ADD ) { SortedSet < T > addedValues = new TreeSet < > ( newValues ) ; addedValues . removeAll ( originalValues ) ; newMod = PropertyEditorModification . createAddModification ( pd , addedValues , originalValues ) ; } else { newMod = PropertyEditorModification . createSetModification ( pd , new TreeSet < T > ( newValues ) , originalValues ) ; } removeModification ( mod ) ; } else { originalValues = new TreeSet < > ( previousValues ) ; SortedSet < T > addedValues = new TreeSet < > ( newValues ) ; addedValues . removeAll ( originalValues ) ; newMod = PropertyEditorModification . createAddModification ( pd , addedValues , originalValues ) ; } addModification ( newMod ) ; }
register an add modification in the list of modifications .
