/** @file Copyright (c) 2006, Intel Corporation All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ package org.tianocore.frameworkwizard.far; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.tianocore.frameworkwizard.packaging.PackageIdentification; public class AggregationOperation { public static synchronized List union(List list1, List list2) { List result = new ArrayList(); result.addAll(list1); Iterator iter = list2.iterator(); while (iter.hasNext()) { PackageIdentification item = iter.next(); if (!belongs(item, result)) { result.add(item); } } return result; } public static synchronized List intersection(List list1, List list2) { List result = new ArrayList(); Iterator iter = list1.iterator(); while (iter.hasNext()) { PackageIdentification item = iter.next(); if (belongs(item, list2)) { result.add(item); } } return result; } public static synchronized List minus(List list1, List list2) { List result = new ArrayList(); Iterator iter = list1.iterator(); while (iter.hasNext()) { PackageIdentification item = iter.next(); if (!belongs(item, list2)) { result.add(item); } } return result; } public static synchronized boolean belongs(PackageIdentification o, List list) { Iterator iter = list.iterator(); while (iter.hasNext()) { if (iter.next().equalsWithGuid(o)) { return true; } } return false; } public static synchronized List getExistedItems(PackageIdentification o, List list) { List result = new ArrayList(); Iterator iter = list.iterator(); while (iter.hasNext()) { PackageIdentification item = iter.next(); if (item.equalsWithGuid(o)) { result.add(item); } } return result; } }