Java Utililty Methods List Difference

List of utility methods to do List Difference

Description

The list of methods to do List Difference are organized into topic(s).

Method

booleandifferentCategory(String prop1, String prop2, List cat1, List cat2)
checks if one property belongs to some category and the other to different category
return !(cat1 == null || cat2 == null || cat1.isEmpty() || cat2.isEmpty())
        && ((cat1.contains(prop1) && cat2.contains(prop2))
                || (cat1.contains(prop2) && cat2.contains(prop1)));
ListdiffFloats(List a, List b)
diff Floats
List<Double> diffs = new ArrayList<>();
for (int i = 0; i < a.size(); i++) {
    diffs.add((double) a.get(i) - b.get(i));
return diffs;
ListdiffList(List aList, List bList)
Returns a list of String objects that appear aList but don't appear in bList.
List<String> result = new ArrayList<String>();
for (String a : aList) {
    if (bList.contains(a) == false) {
        result.add(a);
return result;
ListdiffSet(List a, List b)
i a - b
List<T> c = new ArrayList<T>();
Map<T, T> map = new HashMap<T, T>();
for (T t : b) {
    map.put(t, t);
for (T t : a) {
    if (map.get(t) == null)
        c.add(t);
...
voiddiffSimple(String name, Object expected, Object actual, List messages)
diff Simple
boolean changed = true;
if (expected == null) {
    if (actual == null)
        changed = false;
} else {
    if (expected.equals(actual))
        changed = false;
if (changed) {
    messages.add("C " + name + ": " + expected + " ==> " + actual);
voidextractDifference(List l1, List l2, List in1not2, List in2not1, List inBothFrom1, List inBothFrom2, Comparator c)
extract Difference
int index1 = 0;
int index2 = 0;
Object o1 = null;
Object o2 = null;
String curr1 = null;
String curr2 = null;
String next1 = null;
String next2 = null;
...
ListformatDifferentFileNames(List results)
format Different File Names
List<String> ret = new ArrayList<String>();
List<String> l1 = new ArrayList<String>();
List<String> l2 = new ArrayList<String>();
for (String str : results) {
    if (isContainNotExist(str)) {
        l1.add(str);
    } else {
        l2.add(str);
...
ListgetDiffentElement(List minList, List maxList)
get Diffent Element
List<String> newList = new ArrayList<String>();
for (String max : maxList) {
    if (!(minList.contains(max))) {
        newList.add(max);
return newList;
ListgetDifference(List bigger, List smaller)
get Difference
final List<T> result = new ArrayList<T>();
for (final T elem1 : bigger)
    if (!smaller.contains(elem1))
        result.add(elem1);
return result;
StringgetDiffInfo(List infoList)
get Diff Info
int iIndex = 1;
boolean isFind = false;
String newItem = "NewItem";
do {
    isFind = false;
    for (String info : infoList) {
        if (info.equals(newItem)) {
            isFind = true;
...