Mercurial > hg > ConflictEditor
changeset 16:47f6cbd38de3
clean code!
author | dirk |
---|---|
date | Sat, 17 Sep 2011 06:49:13 +0200 |
parents | e60d38aa42fe |
children | 27bd115e171c |
files | conflict-editor/src/main/java/de/codedo/conflicteditor/DocumentMatcher.java |
diffstat | 1 files changed, 23 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/conflict-editor/src/main/java/de/codedo/conflicteditor/DocumentMatcher.java Fri Sep 16 17:03:57 2011 +0200 +++ b/conflict-editor/src/main/java/de/codedo/conflicteditor/DocumentMatcher.java Sat Sep 17 06:49:13 2011 +0200 @@ -44,11 +44,7 @@ private void createDifferencesFromFieldsOnlyAvailableInOriginal() { - Set<String> originalFieldNames = getFieldNames(_original); - Set<String> otherFieldNames = getFieldNames(_other); - originalFieldNames.removeAll(otherFieldNames); - - for (String name : originalFieldNames) + for (String name : calculateFieldNamesInOriginalOnly()) { // TODO value may not be text String value = _original.findValue(name).getTextValue(); @@ -57,13 +53,17 @@ } } - private void createDifferencesFromFieldsOnlyAvailableInConflict() + private Set<String> calculateFieldNamesInOriginalOnly() { Set<String> originalFieldNames = getFieldNames(_original); Set<String> otherFieldNames = getFieldNames(_other); - otherFieldNames.removeAll(originalFieldNames); + originalFieldNames.removeAll(otherFieldNames); + return originalFieldNames; + } - for (String name : otherFieldNames) + private void createDifferencesFromFieldsOnlyAvailableInConflict() + { + for (String name : calculateFieldNamesInOtherOnly()) { // TODO value may not be text String value = _other.findValue(name).getTextValue(); @@ -72,13 +72,17 @@ } } - private void createDifferencesFromFieldValues() + private Set<String> calculateFieldNamesInOtherOnly() { Set<String> originalFieldNames = getFieldNames(_original); Set<String> otherFieldNames = getFieldNames(_other); - originalFieldNames.retainAll(otherFieldNames); + otherFieldNames.removeAll(originalFieldNames); + return otherFieldNames; + } - for (String name : originalFieldNames) + private void createDifferencesFromFieldValues() + { + for (String name : calculateCommonFieldNames()) { Difference difference = compareValuesForKey(name); if (difference != null) @@ -88,6 +92,14 @@ } } + private Set<String> calculateCommonFieldNames() + { + Set<String> originalFieldNames = getFieldNames(_original); + Set<String> otherFieldNames = getFieldNames(_other); + originalFieldNames.retainAll(otherFieldNames); + return originalFieldNames; + } + private Difference compareValuesForKey(String key) { JsonNode original = _original.findValue(key);