package de.exciteproject.refext.extract;

import java.util.HashMap;
import java.util.Map;

/**
 * Container class for describing the annotation format used in
 * {@link ReferenceLineAnnotator}.
 */
public class ReferenceLineAnnotation {
    private String line;
    private Map<String, Double> annotations;

    public ReferenceLineAnnotation(String line) {
        this.line = line;
        this.annotations = new HashMap<String, Double>();
    }

    public void addAnnotation(String label, Double value) {
        this.annotations.put(label, value);
    }

    public String getBestAnnotation() {
        Map.Entry<String, Double> maxEntry = null;

        // from: https://stackoverflow.com/a/5911199/2174538
        for (Map.Entry<String, Double> entry : this.annotations.entrySet()) {
            if ((maxEntry == null) || (entry.getValue().compareTo(maxEntry.getValue()) > 0)) {
                maxEntry = entry;
            }
        }
        return maxEntry.getKey();
    }

    public String getLine() {
        return this.line;
    }
}

@@ -230,20 +230,17 @@
 ation %7B%0A
-    
+%09
 private 
@@ -252,20 +252,17 @@
 g line;%0A
-    
+%09
 private 
@@ -295,20 +295,17 @@
 tions;%0A%0A
-    
+%09
 public R
@@ -338,32 +338,26 @@
 ing line) %7B%0A
-        
+%09%09
 this.line = 
@@ -362,24 +362,18 @@
 = line;%0A
-        
+%09%09
 this.ann
@@ -410,35 +410,29 @@
  Double%3E();%0A
-    %7D%0A%0A    
+%09%7D%0A%0A%09
 public void 
@@ -475,24 +475,18 @@
 alue) %7B%0A
-        
+%09%09
 this.ann
@@ -513,27 +513,21 @@
 value);%0A
-    %7D%0A%0A    
+%09%7D%0A%0A%09
 public S
@@ -554,24 +554,18 @@
 ion() %7B%0A
-        
+%09%09
 Map.Entr
@@ -600,24 +600,18 @@
  null;%0A%0A
-        
+%09%09
 // from:
@@ -655,24 +655,18 @@
 2174538%0A
-        
+%09%09
 for (Map
@@ -727,28 +727,19 @@
 et()) %7B%0A
-            
+%09%09%09
 if ((max
@@ -817,24 +817,12 @@
 ) %7B%0A
-                
+%09%09%09%09
 maxE
@@ -839,77 +839,128 @@
 ry;%0A
-            %7D%0A        %7D%0A        return maxEntry.getKey();%0A    %7D%0A%0A    
+%09%09%09%7D%0A%09%09%7D%0A%09%09return maxEntry.getKey();%0A%09%7D%0A%0A%09public Map%3CString, Double%3E getAnnotations() %7B%0A%09%09return this.annotations;%0A%09%7D%0A%0A%09
 publ
@@ -985,16 +985,10 @@
 ) %7B%0A
-        
+%09%09
 retu
@@ -1005,12 +1005,9 @@
 ne;%0A
-    
+%09
 %7D%0A%7D%0A

Add get method for annotations to ReferenceLineAnnotation