0%

ListUtil_Enovia

Class com.matrixone.apps.common.util.ListUtil

public class ListUtil extends java.lang.Object

static method compareLists

1
2
3
4
5
6
7
8
9
10
11
12
13
14
public static void compareLists(java.util.List oldList,
java.util.List newList,
java.util.List addedItems,
java.util.List removedItems,
java.util.List retainedItems)
Compare two lists and determine the added, removed, and retained items.
Parameters:
oldList - the old list to compare
newList - the new list to compare
addedItems - items that are only in the new list
removedItems - items that are only in the old list
retainedItems - items that are in both lists
Since:
AEF 9.5.1.0

For Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
StringList list3 = new StringList();
list3.add("1");
list3.add("11");
list3.add("1111");
list3.add("11111");

StringList list4 = new StringList();
list4.add("11");
list4.add("21");
list4.add("111");
list4.add("211");
list4.add("311");

StringList added = new StringList();
StringList removed = new StringList();
StringList retained = new StringList();
ListUtil.compareLists(list3, list4, added, removed, retained);
System.out.println("list 3: " + list3);
System.out.println("list 4: " + list4);
System.out.println("list added: " + added);
System.out.println("list removed: " + removed);
System.out.println("list retained: " + retained);

Output:

list 3: [1, 11, 1111, 11111]
list 4: [11, 21, 111, 211, 311]
list added: [21, 111, 211, 311]
list removed: [1, 1111, 11111]
list retained: [11]