@ -46,6 +46,7 @@ package org.eclipse.jgit.transport;
import java.io.IOException ;
import java.io.IOException ;
import java.text.MessageFormat ;
import java.text.MessageFormat ;
import java.util.ArrayList ;
import java.util.ArrayList ;
import java.util.Collection ;
import java.util.List ;
import java.util.List ;
import org.eclipse.jgit.internal.JGitText ;
import org.eclipse.jgit.internal.JGitText ;
@ -127,26 +128,46 @@ public class ReceiveCommand {
}
}
/ * *
/ * *
* Filter a list of commands according to result .
* Filter a collection of commands according to result .
*
*
* @param commands
* @param in
* commands to filter .
* commands to filter .
* @param want
* @param want
* desired status to filter by .
* desired status to filter by .
* @return a copy of the command list containing only those commands with
* @return a copy of the command list containing only those commands with
* the desired status .
* the desired status .
* @since 2 . 0
* @since 4 . 3
* /
* /
public static List < ReceiveCommand > filter ( List < ReceiveCommand > commands ,
public static List < ReceiveCommand > filter ( Iterable < ReceiveCommand > in ,
final Result want ) {
Result want ) {
List < ReceiveCommand > r = new ArrayList < ReceiveCommand > ( commands . size ( ) ) ;
List < ReceiveCommand > r ;
for ( final ReceiveCommand cmd : commands ) {
if ( in instanceof Collection )
r = new ArrayList < > ( ( ( Collection < ? > ) in ) . size ( ) ) ;
else
r = new ArrayList < > ( ) ;
for ( ReceiveCommand cmd : in ) {
if ( cmd . getResult ( ) = = want )
if ( cmd . getResult ( ) = = want )
r . add ( cmd ) ;
r . add ( cmd ) ;
}
}
return r ;
return r ;
}
}
/ * *
* 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 .
* @since 2 . 0
* /
public static List < ReceiveCommand > filter ( List < ReceiveCommand > commands ,
Result want ) {
return filter ( ( Iterable < ReceiveCommand > ) commands , want ) ;
}
private final ObjectId oldId ;
private final ObjectId oldId ;
private final ObjectId newId ;
private final ObjectId newId ;