From 7afdc3c09a6be40500a6650a4310363f662e1c9e Mon Sep 17 00:00:00 2001
From: Florian Heck <florian.heck@hotmail.de>
Date: Mon, 17 Oct 2016 14:57:39 +0200
Subject: [PATCH] refactored generic pair to specific merge conflict bean

---
 .../seibt/gitwrapper/repo/MergeConflict.java  | 21 +++++++++++++++++++
 .../fim/seibt/gitwrapper/repo/Repository.java | 13 ++++++------
 .../fim/seibt/gitwrapper/util/Pair.java       | 19 -----------------
 3 files changed, 27 insertions(+), 26 deletions(-)
 create mode 100644 src/de/uni_passau/fim/seibt/gitwrapper/repo/MergeConflict.java
 delete mode 100644 src/de/uni_passau/fim/seibt/gitwrapper/util/Pair.java

diff --git a/src/de/uni_passau/fim/seibt/gitwrapper/repo/MergeConflict.java b/src/de/uni_passau/fim/seibt/gitwrapper/repo/MergeConflict.java
new file mode 100644
index 0000000..bfd1342
--- /dev/null
+++ b/src/de/uni_passau/fim/seibt/gitwrapper/repo/MergeConflict.java
@@ -0,0 +1,21 @@
+package de.uni_passau.fim.seibt.gitwrapper.repo;
+
+import java.util.List;
+
+public class MergeConflict {
+    private final List<BlameLine> left;
+    private final List<BlameLine> right;
+
+    public MergeConflict(List<BlameLine> left, List<BlameLine> right) {
+        this.left = left;
+        this.right = right;
+    }
+
+    public List<BlameLine> getLeft() {
+        return left;
+    }
+
+    public List<BlameLine> getRight() {
+        return right;
+    }
+}
diff --git a/src/de/uni_passau/fim/seibt/gitwrapper/repo/Repository.java b/src/de/uni_passau/fim/seibt/gitwrapper/repo/Repository.java
index 1f66e8d..468d97e 100644
--- a/src/de/uni_passau/fim/seibt/gitwrapper/repo/Repository.java
+++ b/src/de/uni_passau/fim/seibt/gitwrapper/repo/Repository.java
@@ -1,7 +1,6 @@
 package de.uni_passau.fim.seibt.gitwrapper.repo;
 
 import de.uni_passau.fim.seibt.gitwrapper.process.ProcessExecutor.ExecRes;
-import de.uni_passau.fim.seibt.gitwrapper.util.Pair;
 import org.apache.commons.io.FileUtils;
 
 import java.io.File;
@@ -420,20 +419,20 @@ public class Repository {
      * @param file the file to analyze
      * @return list of failed chunks
      */
-    public Optional<List<Pair<List<BlameLine>, List<BlameLine>>>> blameMergeConflicts(Path file) {
+    public Optional<List<MergeConflict>> blameMergeConflicts(Path file) {
         Optional<List<BlameLine>> blame = blameFile(file);
 
         if (!blame.isPresent()) {
             return Optional.empty();
         }
 
-        List<Pair<List<BlameLine>, List<BlameLine>>> conflicts = new ArrayList<>();
+        List<MergeConflict> conflicts = new ArrayList<>();
 
-        Pair<List<BlameLine>, List<BlameLine>> currentConflict = null;
+        MergeConflict currentConflict = null;
         String lastMarker = null;
         for (BlameLine line : blame.get()) {
             if (line.line.startsWith(CONFLICT_START)) {
-                currentConflict = new Pair<>(new ArrayList<>(), new ArrayList<>());
+                currentConflict = new MergeConflict(new ArrayList<>(), new ArrayList<>());
                 lastMarker = CONFLICT_START;
             } else if (line.line.startsWith(CONFLICT_MIDDLE)) {
                 lastMarker = CONFLICT_MIDDLE;
@@ -442,10 +441,10 @@ public class Repository {
                 lastMarker = CONFLICT_END;
             } else if (Objects.equals(lastMarker, CONFLICT_START)) {
                 //noinspection ConstantConditions: there is always a start marker before a relevant line.
-                currentConflict.getKey().add(line);
+                currentConflict.getLeft().add(line);
             } else if (Objects.equals(lastMarker, CONFLICT_MIDDLE)) {
                 //noinspection ConstantConditions: there is always a start marker before a relevant line.
-                currentConflict.getValue().add(line);
+                currentConflict.getRight().add(line);
             }
         }
 
diff --git a/src/de/uni_passau/fim/seibt/gitwrapper/util/Pair.java b/src/de/uni_passau/fim/seibt/gitwrapper/util/Pair.java
deleted file mode 100644
index f856306..0000000
--- a/src/de/uni_passau/fim/seibt/gitwrapper/util/Pair.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package de.uni_passau.fim.seibt.gitwrapper.util;
-
-public class Pair<T, V> {
-    private final T key;
-    private final V value;
-
-    public Pair(T key, V value) {
-        this.key = key;
-        this.value = value;
-    }
-
-    public T getKey() {
-        return key;
-    }
-
-    public V getValue() {
-        return value;
-    }
-}
-- 
GitLab