package net.sf.jabref.model.entry;

import java.util.ArrayList;
import java.util.List;

public class EntryUtil {

    /**
     * Static equals that can also return the right result when one of the objects is null.
     *
     * @param one The object whose equals method is called if the first is not null.
     * @param two The object passed to the first one if the first is not null.
     * @return <code>one == null ? two == null : one.equals(two);</code>
     */
    public static boolean equals(Object one, Object two) {
        return one == null ? two == null : one.equals(two);
    }

    public static String capitalizeFirst(String toCapitalize) {
        // Make first character of String uppercase, and the
        // rest lowercase.
        if (toCapitalize.length() > 1) {
            return toCapitalize.substring(0, 1).toUpperCase() + toCapitalize.substring(1, toCapitalize.length()).toLowerCase();
        } else {
            return toCapitalize.toUpperCase();
        }

    }

    /**
     * Build a String array containing all those elements of all that are not
     * in subset.
     * @param all The array of all values.
     * @param subset The subset of values.
     * @return The remainder that is not part of the subset.
     */
    public static List<String> getRemainder(List<String> all, List<String> subset) {
    	if (subset.size() == 0) {
    		return all;
    	}
    	if (all.equals(subset)) {
    		return new ArrayList<>();
    	}

        ArrayList<String> al = new ArrayList<>();
        for (String anAll : all) {
            boolean found = false;
            for (String aSubset : subset) {
                if (aSubset.equals(anAll)) {
                    found = true;
                    break;
                }
            }
            if (!found) {
                al.add(anAll);
            }
        }
        return al;
    }
}

@@ -57,16 +57,46 @@
 ayList;%0A
+import java.util.Collections;%0A
 import j
@@ -623,78 +623,18 @@
     
-public static String capitalizeFirst(String toCapitalize) %7B
+/**
 %0A     
-   //
+*
  Mak
@@ -689,13 +689,9 @@
     
-   //
+*
  res
@@ -703,16 +703,88 @@
 ercase.%0A
+     */%0A    public static String capitalizeFirst(String toCapitalize) %7B%0A
         
@@ -877,16 +877,36 @@
 erCase()
+%0A                   
  + toCap
@@ -1146,24 +1146,31 @@
  in subset.%0A
+     *%0A
      * @para
@@ -1299,24 +1299,58 @@
  the subset.
+ - The result MUST NOT be modified
 %0A     */%0A   
@@ -1431,25 +1431,28 @@
 bset) %7B%0A    
-%09
+    
 if (subset.s
@@ -1454,53 +1454,148 @@
 set.
-size() == 0) %7B%0A    %09%09return all
+isEmpty()) %7B%0A            // ensure that %22all%22 does not get modified%0A            return Collections.unmodifiableList(all)
 ;%0A    
+ 
-%09%7D%0A
+   %7D%0A  
     
-%09
+  
 if (
@@ -1624,41 +1624,55 @@
     
-%09%09return new ArrayList%3C%3E()
+        return Collections.EMPTY_LIST
 ;%0A    
-%09
+    
 %7D%0A%0A 

move comment, reformat, tweak getRemainder that all results are unmodifiable