aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceiveCommand.java
diff options
context:
space:
mode:
authorDave Borowitz <dborowitz@google.com>2012-02-27 12:15:49 -0800
committerShawn O. Pearce <spearce@spearce.org>2012-02-29 19:09:24 -0800
commitd023f2c78bb18ae81817436fb592cd51283eede4 (patch)
treedc0070a7730921f12cc8848f1ee330f3f0e8169c /org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceiveCommand.java
parent903e1b81d43af97e9aff611c77e82cb0969530d8 (diff)
downloadjgit-d023f2c78bb18ae81817436fb592cd51283eede4.tar.gz
jgit-d023f2c78bb18ae81817436fb592cd51283eede4.zip
Extract filterCommands as a static method on ReceiveCommand
Change-Id: I24501f95185878d09b54562e48cb4e7e45dd3968
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceiveCommand.java')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceiveCommand.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceiveCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceiveCommand.java
index a1788d1282..b5ee206eb0 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceiveCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceiveCommand.java
@@ -45,6 +45,8 @@ package org.eclipse.jgit.transport;
import java.io.IOException;
import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
import org.eclipse.jgit.JGitText;
import org.eclipse.jgit.lib.ObjectId;
@@ -120,6 +122,26 @@ public class ReceiveCommand {
OK;
}
+ /**
+ * Filter a list of commands according to result.
+ *
+ * @param commands
+ * commands to filter.
+ * @param want
+ * desired status to filter by.
+ * @return a copy of the command list containing only those commands with the
+ * desired status.
+ */
+ public static List<ReceiveCommand> filter(List<ReceiveCommand> commands,
+ final Result want) {
+ List<ReceiveCommand> r = new ArrayList<ReceiveCommand>(commands.size());
+ for (final ReceiveCommand cmd : commands) {
+ if (cmd.getResult() == want)
+ r.add(cmd);
+ }
+ return r;
+ }
+
private final ObjectId oldId;
private final ObjectId newId;