Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/purge/MultiBranchProvider.java')
-rw-r--r--plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/purge/MultiBranchProvider.java59
1 files changed, 59 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/purge/MultiBranchProvider.java b/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/purge/MultiBranchProvider.java
new file mode 100644
index 00000000000..8892474ae93
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/purge/MultiBranchProvider.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.branch.management.purge;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.core.model.cache.BranchFilter;
+import org.eclipse.osee.framework.core.util.Conditions;
+
+/**
+ * @author John Misinco
+ */
+public class MultiBranchProvider implements IBranchesProvider {
+
+ private final boolean recursive;
+ private final Set<Branch> branches;
+ private final BranchFilter filter;
+
+ public MultiBranchProvider(boolean recursive, Set<Branch> branches, BranchFilter filter) {
+ this.recursive = recursive;
+ this.branches = branches;
+ this.filter = filter;
+ }
+
+ private Collection<Branch> getChildBranches(Branch branch) throws OseeCoreException {
+ Set<Branch> children = new HashSet<Branch>();
+
+ branch.getChildBranches(children, true, filter);
+ if (filter.matches(branch)) {
+ children.add(branch);
+ }
+ return children;
+ }
+
+ @Override
+ public Collection<Branch> getBranches() throws OseeCoreException {
+ Conditions.checkNotNull(branches, "seeds");
+ Set<Branch> result = branches;
+ if (recursive) {
+ result = new HashSet<Branch>(branches);
+ for (Branch b : branches) {
+ result.addAll(getChildBranches(b));
+ }
+ }
+ return result;
+ }
+
+}

Back to the top