]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/AggregationOperation.java
Restructuring for better separation of Tool packages.
[mirror_edk2.git] / Tools / Java / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / far / AggregationOperation.java
1 /** @file
2
3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 **/
13
14 package org.tianocore.frameworkwizard.far;
15
16 import java.util.ArrayList;
17 import java.util.Iterator;
18 import java.util.List;
19
20 import org.tianocore.frameworkwizard.packaging.PackageIdentification;
21
22 public class AggregationOperation {
23
24 public static synchronized List<PackageIdentification> union(List<PackageIdentification> list1,
25 List<PackageIdentification> list2) {
26 List<PackageIdentification> result = new ArrayList<PackageIdentification>();
27 result.addAll(list1);
28 Iterator<PackageIdentification> iter = list2.iterator();
29 while (iter.hasNext()) {
30 PackageIdentification item = iter.next();
31 if (!belongs(item, result)) {
32 result.add(item);
33 }
34 }
35 return result;
36 }
37
38 public static synchronized List<PackageIdentification> intersection(List<PackageIdentification> list1,
39 List<PackageIdentification> list2) {
40 List<PackageIdentification> result = new ArrayList<PackageIdentification>();
41 Iterator<PackageIdentification> iter = list1.iterator();
42 while (iter.hasNext()) {
43 PackageIdentification item = iter.next();
44 if (belongs(item, list2)) {
45 result.add(item);
46 }
47 }
48 return result;
49 }
50
51 public static synchronized List<PackageIdentification> minus(List<PackageIdentification> list1,
52 List<PackageIdentification> list2) {
53 List<PackageIdentification> result = new ArrayList<PackageIdentification>();
54 Iterator<PackageIdentification> iter = list1.iterator();
55 while (iter.hasNext()) {
56 PackageIdentification item = iter.next();
57 if (!belongs(item, list2)) {
58 result.add(item);
59 }
60 }
61 return result;
62 }
63
64 public static synchronized boolean belongs(PackageIdentification o, List<PackageIdentification> list) {
65 Iterator<PackageIdentification> iter = list.iterator();
66 while (iter.hasNext()) {
67 if (iter.next().equalsWithGuid(o)) {
68 return true;
69 }
70 }
71 return false;
72 }
73
74 public static synchronized List<PackageIdentification> getExistedItems(PackageIdentification o,
75 List<PackageIdentification> list) {
76 List<PackageIdentification> result = new ArrayList<PackageIdentification>();
77 Iterator<PackageIdentification> iter = list.iterator();
78 while (iter.hasNext()) {
79 PackageIdentification item = iter.next();
80 if (item.equalsWithGuid(o)) {
81 result.add(item);
82 }
83 }
84 return result;
85 }
86 }