Use Arrays.asList instead of copying array in a for loop
Change-Id: Ie44950f7d2f2f94a0412efb6c274f6e1e31efcd6 Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
parent
39b0b51b12
commit
0b320b2c35
|
@ -60,6 +60,7 @@
|
|||
import java.security.GeneralSecurityException;
|
||||
import java.security.PublicKey;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
|
@ -586,9 +587,7 @@ public ModifiedKeyHandling acceptModifiedServerKey(
|
|||
KeyUtils.getFingerPrint(BuiltinDigests.sha256, expected),
|
||||
KeyUtils.getFingerPrint(BuiltinDigests.md5, actual),
|
||||
KeyUtils.getFingerPrint(BuiltinDigests.sha256, actual));
|
||||
for (String line : warning.split("\n")) { //$NON-NLS-1$
|
||||
messages.add(line);
|
||||
}
|
||||
messages.addAll(Arrays.asList(warning.split("\n"))); //$NON-NLS-1$
|
||||
|
||||
CredentialsProvider provider = getCredentialsProvider(
|
||||
clientSession);
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
|
||||
package org.eclipse.jgit.lib;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -50,8 +51,7 @@ public class Sets {
|
|||
@SafeVarargs
|
||||
public static <T> Set<T> of(T... elements) {
|
||||
Set<T> ret = new HashSet<>();
|
||||
for (T element : elements)
|
||||
ret.add(element);
|
||||
ret.addAll(Arrays.asList(elements));
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
|
@ -854,8 +855,7 @@ private File writeGlobalAttributeFile(String fileName, String... attributes)
|
|||
|
||||
static Set<Attribute> asSet(Attribute... attrs) {
|
||||
HashSet<Attribute> result = new HashSet<>();
|
||||
for (Attribute attr : attrs)
|
||||
result.add(attr);
|
||||
result.addAll(Arrays.asList(attrs));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
import java.io.IOException;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
@ -188,8 +189,7 @@ public List<String> call() throws GitAPIException,
|
|||
public DeleteBranchCommand setBranchNames(String... branchnames) {
|
||||
checkCallable();
|
||||
this.branchNames.clear();
|
||||
for (String branch : branchnames)
|
||||
this.branchNames.add(branch);
|
||||
this.branchNames.addAll(Arrays.asList(branchnames));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
import java.io.IOException;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
@ -135,8 +136,7 @@ public List<String> call() throws GitAPIException {
|
|||
public DeleteTagCommand setTags(String... tags) {
|
||||
checkCallable();
|
||||
this.tags.clear();
|
||||
for (String tagName : tags)
|
||||
this.tags.add(tagName);
|
||||
this.tags.addAll(Arrays.asList(tags));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
package org.eclipse.jgit.revwalk.filter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
|
||||
import org.eclipse.jgit.errors.MissingObjectException;
|
||||
|
@ -78,8 +79,7 @@ public static RevFilter has(RevFlag a) {
|
|||
*/
|
||||
public static RevFilter hasAll(RevFlag... a) {
|
||||
final RevFlagSet set = new RevFlagSet();
|
||||
for (RevFlag flag : a)
|
||||
set.add(flag);
|
||||
set.addAll(Arrays.asList(a));
|
||||
return new HasAll(set);
|
||||
}
|
||||
|
||||
|
@ -103,8 +103,7 @@ public static RevFilter hasAll(RevFlagSet a) {
|
|||
*/
|
||||
public static RevFilter hasAny(RevFlag... a) {
|
||||
final RevFlagSet set = new RevFlagSet();
|
||||
for (RevFlag flag : a)
|
||||
set.add(flag);
|
||||
set.addAll(Arrays.asList(a));
|
||||
return new HasAny(set);
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Set;
|
||||
|
@ -214,8 +215,8 @@ private void readAdvertisedRefsImpl() throws IOException {
|
|||
if (nul >= 0) {
|
||||
// The first line (if any) may contain "hidden"
|
||||
// capability values after a NUL byte.
|
||||
for (String c : line.substring(nul + 1).split(" ")) //$NON-NLS-1$
|
||||
remoteCapablities.add(c);
|
||||
remoteCapablities.addAll(
|
||||
Arrays.asList(line.substring(nul + 1).split(" "))); //$NON-NLS-1$
|
||||
line = line.substring(0, nul);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue