Use native constructors instead of Guava to instantiate empty collections

It's not necessary to use Guava's helper methods when instantiating
empty collections. Just use the native constructors.

Change-Id: I7f454909b15924ee49e149edf9f053da9f718502
This commit is contained in:
David Pursehouse
2016-05-03 23:16:15 +09:00
parent b621cb9eb7
commit ccdeae8e64
135 changed files with 394 additions and 383 deletions

View File

@@ -22,8 +22,6 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedMap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import org.eclipse.jgit.lib.PersonIdent;
@@ -32,6 +30,7 @@ import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -39,7 +38,7 @@ import java.util.Set;
public class SchemaUtil {
public static <V> ImmutableSortedMap<Integer, Schema<V>> schemasFromClass(
Class<?> schemasClass, Class<V> valueClass) {
Map<Integer, Schema<V>> schemas = Maps.newHashMap();
Map<Integer, Schema<V>> schemas = new HashMap<>();
for (Field f : schemasClass.getDeclaredFields()) {
if (Modifier.isStatic(f.getModifiers())
&& Modifier.isFinal(f.getModifiers())
@@ -100,7 +99,7 @@ public class SchemaUtil {
Iterable<String> emails) {
Splitter at = Splitter.on('@');
Splitter s = Splitter.on(CharMatcher.anyOf("@.- ")).omitEmptyStrings();
HashSet<String> parts = Sets.newHashSet();
HashSet<String> parts = new HashSet<>();
for (String email : emails) {
if (email == null) {
continue;

View File

@@ -66,6 +66,7 @@ import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
@@ -147,7 +148,7 @@ public class AllChangesIndexer
totalWork >= 0 ? totalWork : MultiProgressMonitor.UNKNOWN);
final Task failedTask = mpm.beginSubTask("failed", MultiProgressMonitor.UNKNOWN);
final List<ListenableFuture<?>> futures = Lists.newArrayList();
final List<ListenableFuture<?>> futures = new ArrayList<>();
final AtomicBoolean ok = new AtomicBoolean(true);
for (final Project.NameKey project : projects) {

View File

@@ -222,7 +222,7 @@ public class ChangeField {
return ImmutableSet.of();
}
Splitter s = Splitter.on('/').omitEmptyStrings();
Set<String> r = Sets.newHashSet();
Set<String> r = new HashSet<>();
for (String path : paths) {
for (String part : s.split(path)) {
r.add(part);
@@ -302,7 +302,7 @@ public class ChangeField {
if (c == null) {
return ImmutableSet.of();
}
Set<Integer> r = Sets.newHashSet();
Set<Integer> r = new HashSet<>();
if (!args.allowsDrafts && c.getStatus() == Change.Status.DRAFT) {
return r;
}
@@ -336,7 +336,7 @@ public class ChangeField {
};
private static Set<String> getRevisions(ChangeData cd) throws OrmException {
Set<String> revisions = Sets.newHashSet();
Set<String> revisions = new HashSet<>();
for (PatchSet ps : cd.patchSets()) {
if (ps.getRevision() != null) {
revisions.add(ps.getRevision().get());
@@ -372,8 +372,8 @@ public class ChangeField {
@Override
public Iterable<String> get(ChangeData input, FillArgs args)
throws OrmException {
Set<String> allApprovals = Sets.newHashSet();
Set<String> distinctApprovals = Sets.newHashSet();
Set<String> allApprovals = new HashSet<>();
Set<String> distinctApprovals = new HashSet<>();
for (PatchSetApproval a : input.currentApprovals()) {
if (a.getValue() != 0 && !a.isLegacySubmit()) {
allApprovals.add(formatLabel(a.getLabel(), a.getValue(),
@@ -505,7 +505,7 @@ public class ChangeField {
@Override
public Iterable<String> get(ChangeData input, FillArgs args)
throws OrmException {
Set<String> r = Sets.newHashSet();
Set<String> r = new HashSet<>();
for (PatchLineComment c : input.publishedComments()) {
r.add(c.getMessage());
}