Apply "type inference for generic instance creation" Java 7 feature

Since GWT 2.6.0 support for Java 7 is added. Simplify creation of
classes in GWT's client code.

Change-Id: I08ff2c189d2874a6b957072912912e4a6089cdd1
This commit is contained in:
David Ostrovsky 2014-01-19 17:39:10 +01:00
parent dd34a05fdf
commit 6ee971b373
74 changed files with 194 additions and 214 deletions

View File

@ -25,9 +25,8 @@ import java.util.Map;
import java.util.Set;
public class ProjectAccessUtil {
public static List<AccessSection> mergeSections(final List<AccessSection> src) {
final Map<String, AccessSection> map =
new LinkedHashMap<String, AccessSection>();
public static List<AccessSection> mergeSections(List<AccessSection> src) {
Map<String, AccessSection> map = new LinkedHashMap<>();
for (final AccessSection section : src) {
if (section.getPermissions().isEmpty()) {
continue;
@ -40,14 +39,14 @@ public class ProjectAccessUtil {
map.put(section.getName(), section);
}
}
return new ArrayList<AccessSection>(map.values());
return new ArrayList<>(map.values());
}
public static List<AccessSection> removeEmptyPermissionsAndSections(
final List<AccessSection> src) {
final Set<AccessSection> sectionsToRemove = new HashSet<AccessSection>();
final Set<AccessSection> sectionsToRemove = new HashSet<>();
for (final AccessSection section : src) {
final Set<Permission> permissionsToRemove = new HashSet<Permission>();
final Set<Permission> permissionsToRemove = new HashSet<>();
for (final Permission permission : section.getPermissions()) {
if (permission.getRules().isEmpty()) {
permissionsToRemove.add(permission);

View File

@ -39,13 +39,13 @@ public class AccessSection extends RefConfigSection implements
public List<Permission> getPermissions() {
if (permissions == null) {
permissions = new ArrayList<Permission>();
permissions = new ArrayList<>();
}
return permissions;
}
public void setPermissions(List<Permission> list) {
Set<String> names = new HashSet<String>();
Set<String> names = new HashSet<>();
for (Permission p : list) {
if (!names.add(p.getName().toLowerCase())) {
throw new IllegalArgumentException();
@ -124,7 +124,7 @@ public class AccessSection extends RefConfigSection implements
if (!super.equals(obj) || !(obj instanceof AccessSection)) {
return false;
}
return new HashSet<Permission>(getPermissions()).equals(new HashSet<Permission>(
return new HashSet<Permission>(getPermissions()).equals(new HashSet<>(
((AccessSection) obj).getPermissions()));
}
}

View File

@ -39,7 +39,7 @@ public class AccountInfoCache {
}
public AccountInfoCache(final Iterable<AccountInfo> list) {
accounts = new HashMap<Account.Id, AccountInfo>();
accounts = new HashMap<>();
for (final AccountInfo ai : list) {
accounts.put(ai.getId(), ai);
}

View File

@ -30,7 +30,7 @@ import java.util.Set;
public class ApprovalDetail {
public static List<ApprovalDetail> sort(Collection<ApprovalDetail> ads,
final int owner) {
List<ApprovalDetail> sorted = new ArrayList<ApprovalDetail>(ads);
List<ApprovalDetail> sorted = new ArrayList<>(ads);
Collections.sort(sorted, new Comparator<ApprovalDetail>() {
public int compare(ApprovalDetail o1, ApprovalDetail o2) {
int byOwner = (o2.account.get() == owner ? 1 : 0)
@ -56,7 +56,7 @@ public class ApprovalDetail {
public ApprovalDetail(final Account.Id id) {
account = id;
approvals = new ArrayList<PatchSetApproval>();
approvals = new ArrayList<>();
}
public Account.Id getAccount() {
@ -73,7 +73,7 @@ public class ApprovalDetail {
public void approved(String label) {
if (approved == null) {
approved = new HashSet<String>();
approved = new HashSet<>();
}
approved.add(label);
hasNonZero = 1;
@ -81,7 +81,7 @@ public class ApprovalDetail {
public void rejected(String label) {
if (rejected == null) {
rejected = new HashSet<String>();
rejected = new HashSet<>();
}
rejected.add(label);
hasNonZero = 1;
@ -89,14 +89,14 @@ public class ApprovalDetail {
public void votable(String label) {
if (votable == null) {
votable = new HashSet<String>();
votable = new HashSet<>();
}
votable.add(label);
}
public void value(String label, int value) {
if (values == null) {
values = new HashMap<String, Integer>();
values = new HashMap<>();
}
values.put(label, value);
if (value != 0) {

View File

@ -33,9 +33,9 @@ public class CommentDetail {
private transient Map<Integer, List<PatchLineComment>> forA;
private transient Map<Integer, List<PatchLineComment>> forB;
public CommentDetail(final PatchSet.Id idA, final PatchSet.Id idB) {
this.a = new ArrayList<PatchLineComment>();
this.b = new ArrayList<PatchLineComment>();
public CommentDetail(PatchSet.Id idA, PatchSet.Id idB) {
this.a = new ArrayList<>();
this.b = new ArrayList<>();
this.idA = idA;
this.idB = idB;
}
@ -121,18 +121,18 @@ public class CommentDetail {
// possible for several comments to have the same parent (this can happen if two reviewers
// click Reply on the same comment at the same time). Such comments will be displayed under
// their correct parent in chronological order.
Map<String, List<PatchLineComment>> parentMap = new HashMap<String, List<PatchLineComment>>();
Map<String, List<PatchLineComment>> parentMap = new HashMap<>();
// It's possible to have more than one root comment if two reviewers create a comment on the
// same line at the same time
List<PatchLineComment> rootComments = new ArrayList<PatchLineComment>();
List<PatchLineComment> rootComments = new ArrayList<>();
// Store all the comments in parentMap, keyed by their parent
for (PatchLineComment c : comments) {
String parentUuid = c.getParentUuid();
List<PatchLineComment> l = parentMap.get(parentUuid);
if (l == null) {
l = new ArrayList<PatchLineComment>();
l = new ArrayList<>();
parentMap.put(parentUuid, l);
}
l.add(c);
@ -141,7 +141,7 @@ public class CommentDetail {
// Add the comments in the list, starting with the head and then going through all the
// comments that have it as a parent, and so on
List<PatchLineComment> result = new ArrayList<PatchLineComment>();
List<PatchLineComment> result = new ArrayList<>();
addChildren(parentMap, rootComments, result);
return result;
@ -161,14 +161,12 @@ public class CommentDetail {
}
private Map<Integer, List<PatchLineComment>> index(
final List<PatchLineComment> in) {
final HashMap<Integer, List<PatchLineComment>> r;
r = new HashMap<Integer, List<PatchLineComment>>();
List<PatchLineComment> in) {
HashMap<Integer, List<PatchLineComment>> r = new HashMap<>();
for (final PatchLineComment p : in) {
List<PatchLineComment> l = r.get(p.getLine());
if (l == null) {
l = new ArrayList<PatchLineComment>();
l = new ArrayList<>();
r.put(p.getLine(), l);
}
l.add(p);

View File

@ -54,7 +54,7 @@ public class ContributorAgreement implements Comparable<ContributorAgreement> {
public List<PermissionRule> getAccepted() {
if (accepted == null) {
accepted = new ArrayList<PermissionRule>();
accepted = new ArrayList<>();
}
return accepted;
}

View File

@ -23,7 +23,7 @@ public class GarbageCollectionResult {
protected List<Error> errors;
public GarbageCollectionResult() {
errors = new ArrayList<Error>();
errors = new ArrayList<>();
}
public void addError(Error e) {

View File

@ -92,7 +92,7 @@ public class GlobalCapability {
private static final List<String> NAMES_LC;
static {
NAMES_ALL = new ArrayList<String>();
NAMES_ALL = new ArrayList<>();
NAMES_ALL.add(ACCESS_DATABASE);
NAMES_ALL.add(ADMINISTRATE_SERVER);
NAMES_ALL.add(CREATE_ACCOUNT);
@ -110,7 +110,7 @@ public class GlobalCapability {
NAMES_ALL.add(VIEW_CONNECTIONS);
NAMES_ALL.add(VIEW_QUEUE);
NAMES_LC = new ArrayList<String>(NAMES_ALL.size());
NAMES_LC = new ArrayList<>(NAMES_ALL.size());
for (String name : NAMES_ALL) {
NAMES_LC.add(name.toLowerCase());
}

View File

@ -39,7 +39,7 @@ public class GroupInfoCache {
}
public GroupInfoCache(final Iterable<GroupInfo> list) {
groups = new HashMap<AccountGroup.UUID, GroupInfo>();
groups = new HashMap<>();
for (final GroupInfo gi : list) {
groups.put(gi.getId(), gi);
}

View File

@ -27,7 +27,7 @@ import java.util.Map;
public class LabelType {
public static LabelType withDefaultValues(String name) {
checkName(name);
List<LabelValue> values = new ArrayList<LabelValue>(2);
List<LabelValue> values = new ArrayList<>(2);
values.add(new LabelValue((short) 0, "Rejected"));
values.add(new LabelValue((short) 1, "Approved"));
return new LabelType(name, values);
@ -75,7 +75,7 @@ public class LabelType {
}
private static List<LabelValue> sortValues(List<LabelValue> values) {
values = new ArrayList<LabelValue>(values);
values = new ArrayList<>(values);
if (values.size() <= 1) {
return Collections.unmodifiableList(values);
}
@ -88,7 +88,7 @@ public class LabelType {
short max = values.get(values.size() - 1).getValue();
short v = min;
short i = 0;
List<LabelValue> result = new ArrayList<LabelValue>(max - min + 1);
List<LabelValue> result = new ArrayList<>(max - min + 1);
// Fill in any missing values with empty text.
while (i < values.size()) {
while (v < values.get(i).getValue()) {
@ -252,7 +252,7 @@ public class LabelType {
private void initByValue() {
if (byValue == null) {
byValue = new HashMap<Short, LabelValue>();
byValue = new HashMap<>();
for (final LabelValue v : values) {
byValue.put(v.getValue(), v);
}
@ -261,7 +261,7 @@ public class LabelType {
public List<Integer> getValuesAsList() {
if (intList == null) {
intList = new ArrayList<Integer>(values.size());
intList = new ArrayList<>(values.size());
for (LabelValue v : values) {
intList.add(Integer.valueOf(v.getValue()));
}

View File

@ -52,7 +52,7 @@ public class LabelTypes {
if (byLabel == null) {
synchronized (this) {
if (byLabel == null) {
Map<String, LabelType> l = new HashMap<String, LabelType>();
Map<String, LabelType> l = new HashMap<>();
if (labelTypes != null) {
for (LabelType t : labelTypes) {
l.put(t.getName().toLowerCase(), t);
@ -95,7 +95,7 @@ public class LabelTypes {
if (positions == null) {
synchronized (this) {
if (positions == null) {
Map<String, Integer> p = new HashMap<String, Integer>();
Map<String, Integer> p = new HashMap<>();
if (labelTypes != null) {
int i = 0;
for (LabelType t : labelTypes) {

View File

@ -46,8 +46,8 @@ public class ParameterizedString {
public ParameterizedString(final String pattern) {
final StringBuilder raw = new StringBuilder();
final List<Parameter> prs = new ArrayList<Parameter>(4);
final List<Format> ops = new ArrayList<Format>(4);
final List<Parameter> prs = new ArrayList<>(4);
final List<Format> ops = new ArrayList<>(4);
int i = 0;
while (i < pattern.length()) {
@ -95,7 +95,7 @@ public class ParameterizedString {
/** Get the list of parameter names, ordered by appearance in the pattern. */
public List<String> getParameterNames() {
final ArrayList<String> r = new ArrayList<String>(parameters.size());
final ArrayList<String> r = new ArrayList<>(parameters.size());
for (Parameter p : parameters) {
r.add(p.name);
}
@ -132,7 +132,7 @@ public class ParameterizedString {
}
public final class Builder {
private final Map<String, String> params = new HashMap<String, String>();
private final Map<String, String> params = new HashMap<>();
public Builder replace(final String name, final String value) {
params.put(name, value);
@ -169,7 +169,7 @@ public class ParameterizedString {
Parameter(final String parameter) {
// "parameter[.functions...]" -> (parameter, functions...)
final List<String> names = Arrays.asList(parameter.split("\\."));
final List<Function> functs = new ArrayList<Function>(names.size());
final List<Function> functs = new ArrayList<>(names.size());
if (names.isEmpty()) {
name = "";
@ -207,7 +207,7 @@ public class ParameterizedString {
private static final Map<String, Function> FUNCTIONS = initFunctions();
private static Map<String, Function> initFunctions() {
final HashMap<String, Function> m = new HashMap<String, Function>();
HashMap<String, Function> m = new HashMap<>();
m.put("toLowerCase", new Function() {
@Override
String apply(String a) {

View File

@ -45,7 +45,7 @@ public class PermissionRange implements Comparable<PermissionRange> {
/** @return all values between {@link #getMin()} and {@link #getMax()} */
public List<Integer> getValuesAsList() {
ArrayList<Integer> r = new ArrayList<Integer>(getRangeSize());
ArrayList<Integer> r = new ArrayList<>(getRangeSize());
for (int i = min; i <= max; i++) {
r.add(i);
}

View File

@ -27,7 +27,7 @@ public class ReviewResult {
protected Change.Id changeId;
public ReviewResult() {
errors = new ArrayList<Error>();
errors = new ArrayList<>();
}
public void addError(final Error e) {

View File

@ -28,7 +28,7 @@ public class ReviewerResult {
protected boolean askForConfirmation;
public ReviewerResult() {
errors = new ArrayList<Error>();
errors = new ArrayList<>();
}
public void addError(final Error e) {

View File

@ -31,7 +31,7 @@ public class ParameterizedStringTest {
assertEquals("", p.getRawPattern());
assertTrue(p.getParameterNames().isEmpty());
final Map<String, String> a = new HashMap<String, String>();
final Map<String, String> a = new HashMap<>();
assertNotNull(p.bind(a));
assertEquals(0, p.bind(a).length);
assertEquals("", p.replace(a));
@ -44,7 +44,7 @@ public class ParameterizedStringTest {
assertEquals("${bar}c", p.getRawPattern());
assertTrue(p.getParameterNames().isEmpty());
final Map<String, String> a = new HashMap<String, String>();
final Map<String, String> a = new HashMap<>();
a.put("bar", "frobinator");
assertNotNull(p.bind(a));
assertEquals(0, p.bind(a).length);
@ -59,7 +59,7 @@ public class ParameterizedStringTest {
assertEquals(1, p.getParameterNames().size());
assertTrue(p.getParameterNames().contains("bar"));
final Map<String, String> a = new HashMap<String, String>();
final Map<String, String> a = new HashMap<>();
a.put("bar", "frobinator");
assertNotNull(p.bind(a));
assertEquals(1, p.bind(a).length);
@ -75,7 +75,7 @@ public class ParameterizedStringTest {
assertEquals(1, p.getParameterNames().size());
assertTrue(p.getParameterNames().contains("bar"));
final Map<String, String> a = new HashMap<String, String>();
final Map<String, String> a = new HashMap<>();
a.put("bar", "frobinator");
assertNotNull(p.bind(a));
assertEquals(1, p.bind(a).length);
@ -91,7 +91,7 @@ public class ParameterizedStringTest {
assertEquals(1, p.getParameterNames().size());
assertTrue(p.getParameterNames().contains("bar"));
final Map<String, String> a = new HashMap<String, String>();
final Map<String, String> a = new HashMap<>();
a.put("bar", "frobinator");
assertNotNull(p.bind(a));
assertEquals(1, p.bind(a).length);
@ -107,7 +107,7 @@ public class ParameterizedStringTest {
assertEquals(1, p.getParameterNames().size());
assertTrue(p.getParameterNames().contains("bar"));
final Map<String, String> a = new HashMap<String, String>();
final Map<String, String> a = new HashMap<>();
assertNotNull(p.bind(a));
assertEquals(1, p.bind(a).length);
assertEquals("", p.bind(a)[0]);
@ -120,7 +120,7 @@ public class ParameterizedStringTest {
assertEquals(1, p.getParameterNames().size());
assertTrue(p.getParameterNames().contains("a"));
final Map<String, String> a = new HashMap<String, String>();
final Map<String, String> a = new HashMap<>();
a.put("a", "foo");
assertNotNull(p.bind(a));
@ -141,7 +141,7 @@ public class ParameterizedStringTest {
assertEquals(1, p.getParameterNames().size());
assertTrue(p.getParameterNames().contains("a"));
final Map<String, String> a = new HashMap<String, String>();
final Map<String, String> a = new HashMap<>();
a.put("a", "foo");
assertNotNull(p.bind(a));
@ -162,7 +162,7 @@ public class ParameterizedStringTest {
assertEquals(1, p.getParameterNames().size());
assertTrue(p.getParameterNames().contains("a"));
final Map<String, String> a = new HashMap<String, String>();
final Map<String, String> a = new HashMap<>();
a.put("a", "foo@example.com");
assertNotNull(p.bind(a));
@ -186,7 +186,7 @@ public class ParameterizedStringTest {
assertTrue(p.getParameterNames().contains("userName"));
assertTrue(p.getParameterNames().contains("email"));
final Map<String, String> a = new HashMap<String, String>();
final Map<String, String> a = new HashMap<>();
a.put("userName", "firstName lastName");
a.put("email", "FIRSTNAME.LASTNAME@EXAMPLE.COM");
assertNotNull(p.bind(a));
@ -204,7 +204,7 @@ public class ParameterizedStringTest {
assertEquals(1, p.getParameterNames().size());
assertTrue(p.getParameterNames().contains("a"));
final Map<String, String> a = new HashMap<String, String>();
final Map<String, String> a = new HashMap<>();
a.put("a", "FOO@EXAMPLE.COM");
assertNotNull(p.bind(a));
@ -226,7 +226,7 @@ public class ParameterizedStringTest {
assertEquals(1, p.getParameterNames().size());
assertTrue(p.getParameterNames().contains("a"));
final Map<String, String> a = new HashMap<String, String>();
final Map<String, String> a = new HashMap<>();
a.put("a", "foo@example.com");
assertNotNull(p.bind(a));
@ -248,7 +248,7 @@ public class ParameterizedStringTest {
assertEquals(1, p.getParameterNames().size());
assertTrue(p.getParameterNames().contains("a"));
final Map<String, String> a = new HashMap<String, String>();
final Map<String, String> a = new HashMap<>();
a.put("a", "foo@example.com");
assertNotNull(p.bind(a));
@ -270,7 +270,7 @@ public class ParameterizedStringTest {
assertEquals(1, p.getParameterNames().size());
assertTrue(p.getParameterNames().contains("a"));
final Map<String, String> a = new HashMap<String, String>();
final Map<String, String> a = new HashMap<>();
a.put("a", "foo@example.com");
assertNotNull(p.bind(a));
@ -292,7 +292,7 @@ public class ParameterizedStringTest {
assertEquals(1, p.getParameterNames().size());
assertTrue(p.getParameterNames().contains("a"));
final Map<String, String> a = new HashMap<String, String>();
final Map<String, String> a = new HashMap<>();
a.put("a", "FOO@EXAMPLE.COM");
assertNotNull(p.bind(a));
@ -314,7 +314,7 @@ public class ParameterizedStringTest {
assertEquals(1, p.getParameterNames().size());
assertTrue(p.getParameterNames().contains("a"));
final Map<String, String> a = new HashMap<String, String>();
final Map<String, String> a = new HashMap<>();
a.put("a", "FOO@EXAMPLE.COM");
assertNotNull(p.bind(a));
@ -336,7 +336,7 @@ public class ParameterizedStringTest {
assertEquals(1, p.getParameterNames().size());
assertTrue(p.getParameterNames().contains("a"));
final Map<String, String> a = new HashMap<String, String>();
final Map<String, String> a = new HashMap<>();
a.put("a", "FOO@EXAMPLE.COM");
assertNotNull(p.bind(a));
@ -358,7 +358,7 @@ public class ParameterizedStringTest {
assertEquals(1, p.getParameterNames().size());
assertTrue(p.getParameterNames().contains("a"));
final Map<String, String> a = new HashMap<String, String>();
final Map<String, String> a = new HashMap<>();
a.put("a", "FOO@EXAMPLE.COM");
assertNotNull(p.bind(a));
@ -380,7 +380,7 @@ public class ParameterizedStringTest {
assertEquals(1, p.getParameterNames().size());
assertTrue(p.getParameterNames().contains("a"));
final Map<String, String> a = new HashMap<String, String>();
final Map<String, String> a = new HashMap<>();
a.put("a", "foo@example.com");
assertNotNull(p.bind(a));

View File

@ -571,7 +571,7 @@ public class Gerrit implements EntryPoint {
menuLeft.clear();
menuRight.clear();
menuBars = new HashMap<String, LinkMenuBar>();
menuBars = new HashMap<>();
final boolean signedIn = isSignedIn();
final GerritConfig cfg = getConfig();

View File

@ -56,7 +56,7 @@ public class GitwebLink {
public String toRevision(String project, String commit) {
ParameterizedString pattern = new ParameterizedString(type.getRevision());
Map<String, String> p = new HashMap<String, String>();
Map<String, String> p = new HashMap<>();
p.put("project", encode(project));
p.put("commit", encode(commit));
return baseUrl + pattern.replace(p);
@ -69,7 +69,7 @@ public class GitwebLink {
public String toProject(final Project.NameKey project) {
ParameterizedString pattern = new ParameterizedString(type.getProject());
final Map<String, String> p = new HashMap<String, String>();
final Map<String, String> p = new HashMap<>();
p.put("project", encode(project.get()));
return baseUrl + pattern.replace(p);
}
@ -77,14 +77,14 @@ public class GitwebLink {
public String toBranch(final Branch.NameKey branch) {
ParameterizedString pattern = new ParameterizedString(type.getBranch());
final Map<String, String> p = new HashMap<String, String>();
final Map<String, String> p = new HashMap<>();
p.put("project", encode(branch.getParentKey().get()));
p.put("branch", encode(branch.get()));
return baseUrl + pattern.replace(p);
}
public String toFile(String project, String commit, String file) {
Map<String, String> p = new HashMap<String, String>();
Map<String, String> p = new HashMap<>();
p.put("project", encode(project));
p.put("commit", encode(commit));
p.put("file", encode(file));
@ -98,7 +98,7 @@ public class GitwebLink {
public String toFileHistory(final Branch.NameKey branch, final String file) {
ParameterizedString pattern = new ParameterizedString(type.getFileHistory());
final Map<String, String> p = new HashMap<String, String>();
final Map<String, String> p = new HashMap<>();
p.put("project", encode(branch.getParentKey().get()));
p.put("branch", encode(branch.get()));
p.put("file", encode(file));

View File

@ -39,8 +39,7 @@ public class SearchSuggestOracle extends HighlightSuggestOracle {
final Response response) {
if ("self".startsWith(request.getQuery())) {
final ArrayList<SuggestOracle.Suggestion> r =
new ArrayList<SuggestOracle.Suggestion>(response
.getSuggestions().size() + 1);
new ArrayList<>(response.getSuggestions().size() + 1);
r.addAll(response.getSuggestions());
r.add(new SuggestOracle.Suggestion() {
@Override
@ -62,7 +61,7 @@ public class SearchSuggestOracle extends HighlightSuggestOracle {
new ParamSuggester(Arrays.asList("ownerin:", "reviewerin:"),
new AccountGroupSuggestOracle()));
private static final TreeSet<String> suggestions = new TreeSet<String>();
private static final TreeSet<String> suggestions = new TreeSet<>();
static {
suggestions.add("age:");
@ -124,7 +123,7 @@ public class SearchSuggestOracle extends HighlightSuggestOracle {
@Override
public void requestDefaultSuggestions(Request request, Callback done) {
final ArrayList<SearchSuggestion> r = new ArrayList<SearchSuggestOracle.SearchSuggestion>();
final ArrayList<SearchSuggestion> r = new ArrayList<>();
// No text - show some default suggestions.
r.add(new SearchSuggestion("status:open", "status:open"));
r.add(new SearchSuggestion("age:1week", "age:1week"));
@ -152,7 +151,7 @@ public class SearchSuggestOracle extends HighlightSuggestOracle {
}
}
final ArrayList<SearchSuggestion> r = new ArrayList<SearchSuggestOracle.SearchSuggestion>();
final ArrayList<SearchSuggestion> r = new ArrayList<>();
for (String suggestion : suggestions.tailSet(lastWord)) {
if ((lastWord.length() < suggestion.length()) && suggestion.startsWith(lastWord)) {
if (suggestion.contains("self") && !Gerrit.isSignedIn()) {
@ -240,8 +239,7 @@ public class SearchSuggestOracle extends HighlightSuggestOracle {
final Response response) {
final String query = request.getQuery();
final List<SearchSuggestOracle.Suggestion> r =
new ArrayList<SuggestOracle.Suggestion>(response
.getSuggestions().size());
new ArrayList<>(response.getSuggestions().size());
for (final SearchSuggestOracle.Suggestion s : response
.getSuggestions()) {
r.add(new SearchSuggestion(s.getDisplayString(),

View File

@ -106,8 +106,7 @@ public class MyIdentitiesScreen extends SettingsScreen {
}
void deleteChecked() {
final HashSet<AccountExternalId.Key> keys =
new HashSet<AccountExternalId.Key>();
final HashSet<AccountExternalId.Key> keys = new HashSet<>();
for (int row = 1; row < table.getRowCount(); row++) {
final AccountExternalId k = getRowItem(row);
if (k == null) {

View File

@ -87,8 +87,7 @@ public class MyWatchesTable extends FancyFlexTable<AccountProjectWatchInfo> {
}
protected Set<AccountProjectWatch.Key> getCheckedIds() {
final Set<AccountProjectWatch.Key> ids =
new HashSet<AccountProjectWatch.Key>();
final Set<AccountProjectWatch.Key> ids = new HashSet<>();
for (int row = 1; row < table.getRowCount(); row++) {
final AccountProjectWatchInfo k = getRowItem(row);
if (k != null && ((CheckBox) table.getWidget(row, 1)).getValue()) {

View File

@ -81,7 +81,7 @@ public class NewAgreementScreen extends AccountScreen {
Util.ACCOUNT_SVC.myAgreements(new GerritCallback<AgreementInfo>() {
public void onSuccess(AgreementInfo result) {
if (isAttached()) {
mySigned = new HashSet<String>(result.accepted);
mySigned = new HashSet<>(result.accepted);
postRPC();
}
}

View File

@ -259,7 +259,7 @@ class SshPanel extends Composite {
}
void deleteChecked() {
final HashSet<Integer> sequenceNumbers = new HashSet<Integer>();
final HashSet<Integer> sequenceNumbers = new HashSet<>();
for (int row = 1; row < table.getRowCount(); row++) {
final SshKeyInfo k = getRowItem(row);
if (k != null && ((CheckBox) table.getWidget(row, 1)).getValue()) {

View File

@ -218,7 +218,7 @@ public class AccessSectionEditor extends Composite implements
}
private void rebuildPermissionSelector() {
List<String> perms = new ArrayList<String>();
List<String> perms = new ArrayList<>();
if (AccessSection.GLOBAL_CAPABILITIES.equals(value.getName())) {
for (String varName : projectAccess.getCapabilities().keySet()) {
@ -261,7 +261,7 @@ public class AccessSectionEditor extends Composite implements
@Override
public void flush() {
List<Permission> src = permissions.getList();
List<Permission> keep = new ArrayList<Permission>(src.size());
List<Permission> keep = new ArrayList<>(src.size());
for (int i = 0; i < src.size(); i++) {
PermissionEditor e = (PermissionEditor) permissionContainer.getWidget(i);

View File

@ -238,7 +238,7 @@ public class AccountGroupMembersScreen extends AccountGroupScreen {
}
void deleteChecked() {
final HashSet<Integer> ids = new HashSet<Integer>();
final HashSet<Integer> ids = new HashSet<>();
for (int row = 1; row < table.getRowCount(); row++) {
final AccountInfo i = getRowItem(row);
if (i != null && ((CheckBox) table.getWidget(row, 1)).getValue()) {
@ -343,7 +343,7 @@ public class AccountGroupMembersScreen extends AccountGroupScreen {
}
void deleteChecked() {
final HashSet<AccountGroup.UUID> ids = new HashSet<AccountGroup.UUID>();
final HashSet<AccountGroup.UUID> ids = new HashSet<>();
for (int row = 1; row < table.getRowCount(); row++) {
final GroupInfo i = getRowItem(row);
if (i != null && ((CheckBox) table.getWidget(row, 1)).getValue()) {

View File

@ -295,7 +295,7 @@ public class PermissionEditor extends Composite implements Editor<Permission>,
@Override
public void flush() {
List<PermissionRule> src = rules.getList();
List<PermissionRule> keep = new ArrayList<PermissionRule>(src.size());
List<PermissionRule> keep = new ArrayList<>(src.size());
for (int i = 0; i < src.size(); i++) {
PermissionRuleEditor e =

View File

@ -25,7 +25,7 @@ class PermissionNameRenderer implements Renderer<String> {
private static final Map<String, String> permissions;
static {
permissions = new HashMap<String, String>();
permissions = new HashMap<>();
for (Map.Entry<String, String> e : Util.C.permissionNames().entrySet()) {
permissions.put(e.getKey(), e.getValue());
permissions.put(e.getKey().toLowerCase(), e.getValue());

View File

@ -137,7 +137,7 @@ public class ProjectAccessEditor extends Composite implements
@Override
public void flush() {
List<AccessSection> src = local.getList();
List<AccessSection> keep = new ArrayList<AccessSection>(src.size());
List<AccessSection> keep = new ArrayList<>(src.size());
for (int i = 0; i < src.size(); i++) {
AccessSectionEditor e = (AccessSectionEditor) localContainer.getWidget(i);

View File

@ -145,7 +145,7 @@ public class ProjectAccessScreen extends ProjectScreen {
private void displayReadOnly(ProjectAccess access) {
this.access = access;
Map<String, String> allCapabilities = new HashMap<String, String>();
Map<String, String> allCapabilities = new HashMap<>();
for (CapabilityInfo c : Natives.asList(capabilityMap.values())) {
allCapabilities.put(c.id(), c.name());
}
@ -233,17 +233,16 @@ public class ProjectAccessScreen extends ProjectScreen {
ProjectAccess newAccess) {
final List<AccessSection> wantedSections =
mergeSections(removeEmptyPermissionsAndSections(wantedAccess.getLocal()));
final HashSet<AccessSection> same =
new HashSet<AccessSection>(wantedSections);
final HashSet<AccessSection> same = new HashSet<>(wantedSections);
final HashSet<AccessSection> different =
new HashSet<AccessSection>(wantedSections.size()
new HashSet<>(wantedSections.size()
+ newAccess.getLocal().size());
different.addAll(wantedSections);
different.addAll(newAccess.getLocal());
same.retainAll(newAccess.getLocal());
different.removeAll(same);
final Set<String> differentNames = new HashSet<String>();
final Set<String> differentNames = new HashSet<>();
for (final AccessSection s : different) {
differentNames.add(s.getName());
}

View File

@ -249,7 +249,7 @@ public class ProjectBranchesScreen extends ProjectScreen {
}
Set<String> getCheckedRefs() {
Set<String> refs = new HashSet<String>();
Set<String> refs = new HashSet<>();
for (int row = 1; row < table.getRowCount(); row++) {
final BranchInfo k = getRowItem(row);
if (k != null && table.getWidget(row, 1) instanceof CheckBox

View File

@ -352,10 +352,10 @@ public class ProjectInfoScreen extends ProjectScreen {
private void initPluginOptions(ConfigInfo info) {
pluginOptionsPanel.clear();
pluginConfigWidgets = new HashMap<String, Map<String, FocusWidget>>();
pluginConfigWidgets = new HashMap<>();
for (String pluginName : info.pluginConfig().keySet()) {
Map<String, FocusWidget> widgetMap = new HashMap<String, FocusWidget>();
Map<String, FocusWidget> widgetMap = new HashMap<>();
pluginConfigWidgets.put(pluginName, widgetMap);
LabeledWidgetsGrid g = new LabeledWidgetsGrid();
g.addHeader(new SmallHeading(Util.M.pluginProjectOptionsTitle(pluginName)));
@ -522,7 +522,7 @@ public class ProjectInfoScreen extends ProjectScreen {
private Map<String, Map<String, String>> getPluginConfigValues() {
Map<String, Map<String, String>> pluginConfigValues =
new HashMap<String, Map<String, String>>(pluginConfigWidgets.size());
new HashMap<>(pluginConfigWidgets.size());
for (Entry<String, Map<String, FocusWidget>> e : pluginConfigWidgets.entrySet()) {
Map<String, String> values =
new HashMap<String, String>(e.getValue().size());

View File

@ -130,7 +130,7 @@ class Actions extends Composite {
}
private static TreeSet<String> filterNonCore(NativeMap<ActionInfo> m) {
TreeSet<String> ids = new TreeSet<String>(m.keySet());
TreeSet<String> ids = new TreeSet<>(m.keySet());
for (String id : CORE) {
ids.remove(id);
}

View File

@ -123,7 +123,7 @@ public class ChangeScreen2 extends Screen {
private KeyCommandSet keysNavigation;
private KeyCommandSet keysAction;
private List<HandlerRegistration> handlers = new ArrayList<HandlerRegistration>(4);
private List<HandlerRegistration> handlers = new ArrayList<>(4);
private UpdateCheckTimer updateCheck;
private Timestamp lastDisplayedUpdate;
private UpdateAvailableBar updateAvailable;
@ -618,8 +618,7 @@ public class ChangeScreen2 extends Screen {
private List<NativeMap<JsArray<CommentInfo>>> loadComments(
RevisionInfo rev, CallbackGroup group) {
final int id = rev._number();
final List<NativeMap<JsArray<CommentInfo>>> r =
new ArrayList<NativeMap<JsArray<CommentInfo>>>(1);
final List<NativeMap<JsArray<CommentInfo>>> r = new ArrayList<>(1);
ChangeApi.revision(changeId.get(), rev.name())
.view("comments")
.get(group.add(new AsyncCallback<NativeMap<JsArray<CommentInfo>>>() {
@ -638,8 +637,7 @@ public class ChangeScreen2 extends Screen {
private List<NativeMap<JsArray<CommentInfo>>> loadDrafts(
RevisionInfo rev, CallbackGroup group) {
final List<NativeMap<JsArray<CommentInfo>>> r =
new ArrayList<NativeMap<JsArray<CommentInfo>>>(1);
final List<NativeMap<JsArray<CommentInfo>>> r = new ArrayList<>(1);
if (Gerrit.isSignedIn()) {
ChangeApi.revision(changeId.get(), rev.name())
.view("drafts")

View File

@ -43,11 +43,11 @@ class History extends FlowPanel {
private ReplyAction replyAction;
private Change.Id changeId;
private final Set<Integer> loaded = new HashSet<Integer>();
private final Set<Integer> loaded = new HashSet<>();
private final Map<AuthorRevision, List<CommentInfo>> byAuthor =
new HashMap<AuthorRevision, List<CommentInfo>>();
new HashMap<>();
private final List<Integer> toLoad = new ArrayList<Integer>(4);
private final List<Integer> toLoad = new ArrayList<>(4);
private int active;
void set(CommentLinkProcessor clp, ReplyAction ra,
@ -109,7 +109,7 @@ class History extends FlowPanel {
AuthorRevision k = new AuthorRevision(c.author(), id);
List<CommentInfo> l = byAuthor.get(k);
if (l == null) {
l = new ArrayList<CommentInfo>();
l = new ArrayList<>();
byAuthor.put(k, l);
}
l.add(c);
@ -175,8 +175,8 @@ class History extends FlowPanel {
}
Timestamp when = msg.date();
List<CommentInfo> match = new ArrayList<CommentInfo>();
List<CommentInfo> other = new ArrayList<CommentInfo>();
List<CommentInfo> match = new ArrayList<>();
List<CommentInfo> other = new ArrayList<>();
for (CommentInfo c : list) {
if (c.updated().compareTo(when) <= 0) {
match.add(c);

View File

@ -100,7 +100,7 @@ class Labels extends Grid {
}
boolean set(ChangeInfo info, boolean current) {
List<String> names = new ArrayList<String>(info.labels());
List<String> names = new ArrayList<>(info.labels());
Collections.sort(names);
boolean canSubmit = info.status().isOpen();
@ -140,14 +140,14 @@ class Labels extends Grid {
}
private Widget renderUsers(LabelInfo label) {
Map<Integer, List<ApprovalInfo>> m = new HashMap<Integer, List<ApprovalInfo>>(4);
Map<Integer, List<ApprovalInfo>> m = new HashMap<>(4);
int approved = 0, rejected = 0;
for (ApprovalInfo ai : Natives.asList(label.all())) {
if (ai.value() != 0) {
List<ApprovalInfo> l = m.get(Integer.valueOf(ai.value()));
if (l == null) {
l = new ArrayList<ApprovalInfo>(label.all().length());
l = new ArrayList<>(label.all().length());
m.put(Integer.valueOf(ai.value()), l);
}
l.add(ai);
@ -183,7 +183,7 @@ class Labels extends Grid {
}
private static List<Integer> sort(Set<Integer> keySet, int a, int b) {
List<Integer> r = new ArrayList<Integer>(keySet);
List<Integer> r = new ArrayList<>(keySet);
Collections.sort(r);
if (keySet.contains(a)) {
r.remove(Integer.valueOf(a));
@ -223,7 +223,7 @@ class Labels extends Grid {
static SafeHtml formatUserList(ChangeScreen2.Style style,
Collection<? extends AccountInfo> in,
Set<Integer> removable) {
List<AccountInfo> users = new ArrayList<AccountInfo>(in);
List<AccountInfo> users = new ArrayList<>(in);
Collections.sort(users, new Comparator<AccountInfo>() {
@Override
public int compare(AccountInfo a, AccountInfo b) {

View File

@ -179,12 +179,11 @@ class Message extends Composite {
private static TreeMap<String, List<CommentInfo>>
byPath(List<CommentInfo> list) {
TreeMap<String, List<CommentInfo>> m =
new TreeMap<String, List<CommentInfo>>();
TreeMap<String, List<CommentInfo>> m = new TreeMap<>();
for (CommentInfo c : list) {
List<CommentInfo> l = m.get(c.path());
if (l == null) {
l = new ArrayList<CommentInfo>();
l = new ArrayList<>();
m.put(c.path(), l);
}
l.add(c);

View File

@ -133,7 +133,7 @@ public class RelatedChanges extends TabPanel {
private int outstandingCallbacks;
RelatedChanges() {
tabs = new ArrayList<RelatedChangesTab>(Tab.values().length);
tabs = new ArrayList<>(Tab.values().length);
selectedTab = -1;
setVisible(false);

View File

@ -163,7 +163,7 @@ class RelatedChangesTab implements IsWidget {
this.revision = revision;
this.changes = changes;
this.navList = navList;
rows = new ArrayList<SafeHtml>(changes.length());
rows = new ArrayList<>(changes.length());
connectedPos = changes.length() - 1;
connected = showIndirectAncestors
? new HashSet<String>(Math.max(changes.length() * 4 / 3, 16))

View File

@ -115,7 +115,7 @@ class ReplyBox extends Composite {
this.revision = revision;
initWidget(uiBinder.createAndBindUi(this));
List<String> names = new ArrayList<String>(permitted.keySet());
List<String> names = new ArrayList<>(permitted.keySet());
if (names.isEmpty()) {
UIObject.setVisible(labelsParent, false);
} else {
@ -281,13 +281,12 @@ class ReplyBox extends Composite {
List<String> names,
NativeMap<LabelInfo> all,
NativeMap<JsArrayString> permitted) {
TreeSet<Short> values = new TreeSet<Short>();
List<LabelAndValues> labels =
new ArrayList<LabelAndValues>(permitted.size());
TreeSet<Short> values = new TreeSet<>();
List<LabelAndValues> labels = new ArrayList<>(permitted.size());
for (String id : names) {
JsArrayString p = permitted.get(id);
if (p != null) {
Set<Short> a = new TreeSet<Short>();
Set<Short> a = new TreeSet<>();
for (int i = 0; i < p.length(); i++) {
a.add(LabelInfo.parseValue(p.get(i)));
}
@ -295,7 +294,7 @@ class ReplyBox extends Composite {
values.addAll(a);
}
}
List<Short> columns = new ArrayList<Short>(values);
List<Short> columns = new ArrayList<>(values);
labelsTable.resize(1 + labels.size(), 2 + values.size());
for (int c = 0; c < columns.size(); c++) {
@ -303,8 +302,7 @@ class ReplyBox extends Composite {
labelsTable.getCellFormatter().setStyleName(0, 1 + c, style.label_value());
}
List<LabelAndValues> checkboxes =
new ArrayList<LabelAndValues>(labels.size());
List<LabelAndValues> checkboxes = new ArrayList<>(labels.size());
int row = 1;
for (LabelAndValues lv : labels) {
if (isCheckBox(lv.info.value_set())) {
@ -413,7 +411,7 @@ class ReplyBox extends Composite {
Util.C.commitMessage(), copyPath(Patch.COMMIT_MSG, l)));
}
List<String> paths = new ArrayList<String>(m.keySet());
List<String> paths = new ArrayList<>(m.keySet());
Collections.sort(paths);
for (String path : paths) {
@ -452,7 +450,7 @@ class ReplyBox extends Composite {
LabelRadioGroup(int row, String label, int cnt) {
this.row = row;
this.label = label;
this.buttons = new ArrayList<LabelRadioButton>(cnt);
this.buttons = new ArrayList<>(cnt);
}
void select(LabelRadioButton b) {

View File

@ -42,7 +42,7 @@ public class RestReviewerSuggestOracle extends SuggestAfterTypingNCharsOracle {
@Override
public void onSuccess(JsArray<SuggestReviewerInfo> result) {
final List<RestReviewerSuggestion> r =
new ArrayList<RestReviewerSuggestion>(result.length());
new ArrayList<>(result.length());
for (final SuggestReviewerInfo reviewer : Natives.asList(result)) {
r.add(new RestReviewerSuggestion(reviewer));
}

View File

@ -209,8 +209,8 @@ class Reviewers extends Composite {
}
private void display(ChangeInfo info) {
Map<Integer, AccountInfo> r = new HashMap<Integer, AccountInfo>();
Map<Integer, AccountInfo> cc = new HashMap<Integer, AccountInfo>();
Map<Integer, AccountInfo> r = new HashMap<>();
Map<Integer, AccountInfo> cc = new HashMap<>();
for (LabelInfo label : Natives.asList(info.all_labels().values())) {
if (label.all() != null) {
for (ApprovalInfo ai : Natives.asList(label.all())) {
@ -224,7 +224,7 @@ class Reviewers extends Composite {
r.remove(info.owner()._account_id());
cc.remove(info.owner()._account_id());
Set<Integer> removable = new HashSet<Integer>();
Set<Integer> removable = new HashSet<>();
if (info.removable_reviewers() != null) {
for (AccountInfo a : Natives.asList(info.removable_reviewers())) {
removable.add(a._account_id());

View File

@ -45,7 +45,7 @@ abstract class UpdateAvailableBar extends Composite {
}
void set(List<MessageInfo> newMessages, Timestamp newTime) {
HashSet<Integer> seen = new HashSet<Integer>();
HashSet<Integer> seen = new HashSet<>();
StringBuilder r = new StringBuilder();
for (MessageInfo m : newMessages) {
int a = m.author() != null ? m.author()._account_id() : 0;

View File

@ -71,7 +71,7 @@ public class ApprovalTable extends Composite {
private Map<Integer, Integer> rows;
public ApprovalTable() {
rows = new HashMap<Integer, Integer>();
rows = new HashMap<>();
table = new Grid(1, 3);
table.addStyleName(Gerrit.RESOURCES.css().infoTable());
@ -138,10 +138,8 @@ public class ApprovalTable extends Composite {
void display(ChangeInfo change) {
lastChange = change;
reviewerSuggestOracle.setChange(change.legacy_id());
Map<Integer, ApprovalDetail> byUser =
new LinkedHashMap<Integer, ApprovalDetail>();
Map<Integer, AccountInfo> accounts =
new LinkedHashMap<Integer, AccountInfo>();
Map<Integer, ApprovalDetail> byUser = new LinkedHashMap<>();
Map<Integer, AccountInfo> accounts = new LinkedHashMap<>();
List<String> missingLabels = initLabels(change, accounts, byUser);
removeAllChildren(missing.getElement());
@ -152,7 +150,7 @@ public class ApprovalTable extends Composite {
if (byUser.isEmpty()) {
table.setVisible(false);
} else {
List<String> labels = new ArrayList<String>(change.labels());
List<String> labels = new ArrayList<>(change.labels());
Collections.sort(labels);
displayHeader(labels);
table.resizeRows(1 + byUser.size());
@ -187,7 +185,7 @@ public class ApprovalTable extends Composite {
private Set<Integer> removableReviewers(ChangeInfo change) {
Set<Integer> result =
new HashSet<Integer>(change.removable_reviewers().length());
new HashSet<>(change.removable_reviewers().length());
for (int i = 0; i < change.removable_reviewers().length(); i++) {
result.add(change.removable_reviewers().get(i)._account_id());
}
@ -198,7 +196,7 @@ public class ApprovalTable extends Composite {
Map<Integer, AccountInfo> accounts,
Map<Integer, ApprovalDetail> byUser) {
Set<Integer> removableReviewers = removableReviewers(change);
List<String> missing = new ArrayList<String>();
List<String> missing = new ArrayList<>();
for (String name : change.labels()) {
LabelInfo label = change.label(name);

View File

@ -23,8 +23,7 @@ import java.util.Map;
/** A Cache to store common client side data by change */
public class ChangeCache {
private static Map<Change.Id, ChangeCache> caches =
new HashMap<Change.Id, ChangeCache>();
private static Map<Change.Id, ChangeCache> caches = new HashMap<>();
public static ChangeCache get(Change.Id chg) {
ChangeCache cache = caches.get(chg);
@ -56,7 +55,7 @@ public class ChangeCache {
public ListenableValue<ChangeInfo> getChangeInfoCache() {
if (info == null) {
info = new ListenableValue<ChangeInfo>();
info = new ListenableValue<>();
}
return info;
}

View File

@ -171,7 +171,7 @@ public class ChangeDetailCache extends ListenableValue<ChangeDetail> {
}
public static AccountInfoCache users(ChangeInfo info) {
Map<Integer, AccountInfo> r = new HashMap<Integer, AccountInfo>();
Map<Integer, AccountInfo> r = new HashMap<>();
add(r, info.owner());
if (info.messages() != null) {
for (MessageInfo m : Natives.asList(info.messages())) {
@ -196,7 +196,7 @@ public class ChangeDetailCache extends ListenableValue<ChangeDetail> {
}
private static List<ChangeMessage> toMessages(ChangeInfo info) {
List<ChangeMessage> msgs = new ArrayList<ChangeMessage>();
List<ChangeMessage> msgs = new ArrayList<>();
for (MessageInfo m : Natives.asList(info.messages())) {
ChangeMessage o = new ChangeMessage(
new ChangeMessage.Key(
@ -219,7 +219,7 @@ public class ChangeDetailCache extends ListenableValue<ChangeDetail> {
JsArray<RevisionInfo> all = info.revisions().values();
RevisionInfo.sortRevisionInfoByNumber(all);
List<PatchSet> r = new ArrayList<PatchSet>(all.length());
List<PatchSet> r = new ArrayList<>(all.length());
for (RevisionInfo rev : Natives.asList(all)) {
r.add(toPatchSet(info, rev));
}

View File

@ -173,7 +173,7 @@ public class ChangeInfo extends JavaScriptObject {
}
public final SortedSet<Short> value_set() {
SortedSet<Short> values = new TreeSet<Short>();
SortedSet<Short> values = new TreeSet<>();
for (String v : values()) {
values.add(parseValue(v));
}

View File

@ -71,7 +71,7 @@ public class ChangeTable2 extends NavigationTable<ChangeInfo> {
keysAction.add(new StarKeyCommand(0, 's', Util.C.changeTableStar()));
}
sections = new ArrayList<Section>();
sections = new ArrayList<>();
table.setText(0, C_STAR, "");
table.setText(0, C_SUBJECT, Util.C.changeTableColumnSubject());
table.setText(0, C_STATUS, Util.C.changeTableColumnStatus());
@ -157,7 +157,7 @@ public class ChangeTable2 extends NavigationTable<ChangeInfo> {
}
public void updateColumnsForLabels(ChangeList... lists) {
labelNames = new ArrayList<String>();
labelNames = new ArrayList<>();
for (ChangeList list : lists) {
for (int i = 0; i < list.length(); i++) {
for (String name : list.get(i).labels()) {

View File

@ -35,8 +35,8 @@ public class DashboardTable extends ChangeTable2 {
private List<String> queries;
public DashboardTable(String params) {
titles = new ArrayList<String>();
queries = new ArrayList<String>();
titles = new ArrayList<>();
queries = new ArrayList<>();
String foreach = null;
for (String kvPair : params.split("[,;&]")) {
String[] kv = kvPair.split("=", 2);
@ -63,7 +63,7 @@ public class DashboardTable extends ChangeTable2 {
addStyleName(Gerrit.RESOURCES.css().accountDashboard());
sections = new ArrayList<ChangeTable2.Section>();
sections = new ArrayList<>();
int i = 0;
for (String title : titles) {
Section s = new Section();

View File

@ -89,7 +89,7 @@ public class IncludedInTable extends Composite implements
}
private List<String> toList(JsArrayString in) {
List<String> r = new ArrayList<String>();
List<String> r = new ArrayList<>();
if (in != null) {
for (int i = 0; i < in.length(); i++) {
r.add(in.get(i));

View File

@ -34,8 +34,7 @@ import java.util.Map;
/** Supports the star icon displayed on changes and tracking the status. */
public class StarredChanges {
private static final Event.Type<ChangeStarHandler> TYPE =
new Event.Type<ChangeStarHandler>();
private static final Event.Type<ChangeStarHandler> TYPE = new Event.Type<>();
/** Handler that can receive notifications of a change's starred status. */
public static interface ChangeStarHandler {
@ -118,7 +117,7 @@ public class StarredChanges {
private static boolean busy;
private static final Map<Change.Id, Boolean> pending =
new LinkedHashMap<Change.Id, Boolean>(4);
new LinkedHashMap<>(4);
private static void startRequest() {
busy = true;

View File

@ -60,7 +60,7 @@ public class DashboardsTable extends NavigationTable<DashboardInfo> {
}
public void display(JsArray<DashboardList> in) {
Map<String, DashboardInfo> map = new HashMap<String, DashboardInfo>();
Map<String, DashboardInfo> map = new HashMap<>();
for (DashboardList list : Natives.asList(in)) {
for (DashboardInfo d : Natives.asList(list)) {
if (!map.containsKey(d.id())) {
@ -68,7 +68,7 @@ public class DashboardsTable extends NavigationTable<DashboardInfo> {
}
}
}
display(new ArrayList<DashboardInfo>(map.values()));
display(new ArrayList<>(map.values()));
}
public void display(List<DashboardInfo> list) {

View File

@ -93,10 +93,10 @@ class ChunkManager {
}
void render(DiffInfo diff) {
chunks = new ArrayList<DiffChunkInfo>();
markers = new ArrayList<TextMarker>();
undo = new ArrayList<Runnable>();
padding = new ArrayList<LineWidget>();
chunks = new ArrayList<>();
markers = new ArrayList<>();
undo = new ArrayList<>();
padding = new ArrayList<>();
String diffColor = diff.meta_a() == null || diff.meta_b() == null
? DiffTable.style.intralineBg()

View File

@ -62,10 +62,10 @@ class CommentManager {
this.path = path;
this.commentLinkProcessor = clp;
published = new HashMap<String, PublishedBox>();
sideA = new TreeMap<Integer, CommentGroup>();
sideB = new TreeMap<Integer, CommentGroup>();
unsavedDrafts = new HashSet<DraftBox>();
published = new HashMap<>();
sideA = new TreeMap<>();
sideB = new TreeMap<>();
unsavedDrafts = new HashSet<>();
}
SideBySide2 getSideBySide2() {
@ -247,7 +247,7 @@ class CommentManager {
// TODO: This is not optimal, but shouldn't be too costly in most cases.
// Maybe rewrite after done keeping track of diff chunk positions.
for (int boxLine : sideB.tailMap(1).keySet()) {
List<SkippedLine> temp = new ArrayList<SkippedLine>(skips.size() + 2);
List<SkippedLine> temp = new ArrayList<>(skips.size() + 2);
for (SkippedLine skip : skips) {
int startLine = skip.getStartB();
int deltaBefore = boxLine - startLine;

View File

@ -32,8 +32,8 @@ class LineMapper {
void reset() {
lineA = 0;
lineB = 0;
lineMapAtoB = new ArrayList<LineGap>();
lineMapBtoA = new ArrayList<LineGap>();
lineMapAtoB = new ArrayList<>();
lineMapBtoA = new ArrayList<>();
}
int getLineA() {

View File

@ -73,8 +73,8 @@ class OverviewBar extends Composite implements ClickHandler {
OverviewBar() {
initWidget(uiBinder.createAndBindUi(this));
diff = new ArrayList<MarkHandle>();
comments = new HashSet<MarkHandle>();
diff = new ArrayList<>();
comments = new HashSet<>();
addDomHandler(this, ClickEvent.getType());
}

View File

@ -129,7 +129,7 @@ public class SideBySide2 extends Screen {
this.startLine = startLine;
prefs = DiffPreferences.create(Gerrit.getAccountDiffPreference());
handlers = new ArrayList<HandlerRegistration>(6);
handlers = new ArrayList<>(6);
keysNavigation = new KeyCommandSet(Gerrit.C.sectionNavigation());
header = new Header(keysNavigation, base, revision, path);
diffTable = new DiffTable(this, base, revision, path);

View File

@ -48,7 +48,7 @@ class SkipManager {
}
JsArray<Region> regions = diff.content();
List<SkippedLine> skips = new ArrayList<SkippedLine>();
List<SkippedLine> skips = new ArrayList<>();
int lineA = 0, lineB = 0;
for (int i = 0; i < regions.length(); i++) {
Region current = regions.get(i);
@ -78,7 +78,7 @@ class SkipManager {
CodeMirror cmA = host.getCmFromSide(DisplaySide.A);
CodeMirror cmB = host.getCmFromSide(DisplaySide.B);
skipBars = new HashSet<SkipBar>();
skipBars = new HashSet<>();
for (SkippedLine skip : skips) {
SkipBar barA = newSkipBar(cmA, DisplaySide.A, skip);
SkipBar barB = newSkipBar(cmB, DisplaySide.B, skip);

View File

@ -158,7 +158,7 @@ public class DownloadUrlLink extends Anchor implements ClickHandler {
public static List<DownloadUrlLink> createDownloadUrlLinks(String project,
String ref, boolean allowAnonymous) {
List<DownloadUrlLink> urls = new ArrayList<DownloadUrlLink>();
List<DownloadUrlLink> urls = new ArrayList<>();
Set<DownloadScheme> allowedSchemes = Gerrit.getConfig().getDownloadSchemes();
if (allowAnonymous

View File

@ -797,9 +797,8 @@ public abstract class AbstractPatchContentTable extends NavigationTable<Object>
}
protected static class CommentList {
final List<PatchLineComment> comments = new ArrayList<PatchLineComment>();
final List<PublishedCommentPanel> panels =
new ArrayList<PublishedCommentPanel>();
final List<PatchLineComment> comments = new ArrayList<>();
final List<PublishedCommentPanel> panels = new ArrayList<>();
}
public static class NoOpKeyCommand extends NeedsSignInKeyCommand {

View File

@ -34,7 +34,7 @@ import java.util.List;
*/
class HistoryTable extends FancyFlexTable<Patch> {
private final PatchScreen screen;
final List<HistoryRadio> all = new ArrayList<HistoryRadio>();
final List<HistoryRadio> all = new ArrayList<>();
HistoryTable(final PatchScreen parent) {
setStyleName(Gerrit.RESOURCES.css().patchHistoryTable());

View File

@ -93,7 +93,7 @@ public class SideBySideTable extends AbstractPatchContentTable {
@Override
protected void render(final PatchScript script, final PatchSetDetail detail) {
final ArrayList<Object> lines = new ArrayList<Object>();
final ArrayList<Object> lines = new ArrayList<>();
final SafeHtmlBuilder nc = new SafeHtmlBuilder();
isHugeFile = script.isHugeFile();
allocateTableHeader(script, nc);

View File

@ -216,7 +216,7 @@ public class UnifiedDiffTable extends AbstractPatchContentTable {
for (final String line : script.getPatchHeader()) {
appendFileHeader(nc, line);
}
final ArrayList<PatchLine> lines = new ArrayList<PatchLine>();
final ArrayList<PatchLine> lines = new ArrayList<>();
if (hasDifferences(script)) {
if (script.getDisplayMethodA() == DisplayMethod.IMG
@ -357,7 +357,7 @@ public class UnifiedDiffTable extends AbstractPatchContentTable {
}
setAccountInfoCache(cd.getAccounts());
final ArrayList<PatchLineComment> all = new ArrayList<PatchLineComment>();
final ArrayList<PatchLineComment> all = new ArrayList<>();
for (int row = 0; row < table.getRowCount();) {
final List<PatchLineComment> fora;
final List<PatchLineComment> forb;

View File

@ -78,7 +78,7 @@ public class ConfigInfo extends JavaScriptObject {
/*-{ return this.commentlinks; }-*/;
final List<FindReplace> commentlinks() {
JsArray<CommentLinkInfo> cls = commentlinks0().values();
List<FindReplace> commentLinks = new ArrayList<FindReplace>(cls.length());
List<FindReplace> commentLinks = new ArrayList<>(cls.length());
for (int i = 0; i < cls.length(); i++) {
CommentLinkInfo cl = cls.get(i);
if (!cl.enabled()) {

View File

@ -62,8 +62,8 @@ public class CallbackGroup {
}
public CallbackGroup() {
callbacks = new ArrayList<CallbackImpl<?>>();
remaining = new HashSet<CallbackImpl<?>>();
callbacks = new ArrayList<>();
remaining = new HashSet<>();
}
public <T> Callback<T> add(final AsyncCallback<T> cb) {
@ -109,7 +109,7 @@ public class CallbackGroup {
return emptyCallback();
}
CallbackImpl<T> wrapper = new CallbackImpl<T>(cb);
CallbackImpl<T> wrapper = new CallbackImpl<>(cb);
callbacks.add(wrapper);
remaining.add(wrapper);
return wrapper;

View File

@ -28,8 +28,7 @@ import java.util.Map;
/** Suggestion Oracle for AccountGroup entities. */
public class AccountGroupSuggestOracle extends SuggestAfterTypingNCharsOracle {
private Map<String, AccountGroup.UUID> priorResults =
new HashMap<String, AccountGroup.UUID>();
private Map<String, AccountGroup.UUID> priorResults = new HashMap<>();
private Project.NameKey projectName;
@ -43,7 +42,7 @@ public class AccountGroupSuggestOracle extends SuggestAfterTypingNCharsOracle {
public void onSuccess(final List<GroupReference> result) {
priorResults.clear();
final ArrayList<AccountGroupSuggestion> r =
new ArrayList<AccountGroupSuggestion>(result.size());
new ArrayList<>(result.size());
for (final GroupReference p : result) {
r.add(new AccountGroupSuggestion(p));
priorResults.put(p.getName(), p.getUUID());

View File

@ -34,7 +34,7 @@ public class AccountSuggestOracle extends SuggestAfterTypingNCharsOracle {
new GerritCallback<List<AccountInfo>>() {
public void onSuccess(final List<AccountInfo> result) {
final ArrayList<AccountSuggestion> r =
new ArrayList<AccountSuggestion>(result.size());
new ArrayList<>(result.size());
for (final AccountInfo p : result) {
r.add(new AccountSuggestion(p));
}

View File

@ -38,9 +38,9 @@ public class CommentLinkProcessor {
// One or more of the patterns isn't valid on this browser.
// Try to filter the list down and remove the invalid ones.
List<FindReplace> safe = new ArrayList<FindReplace>(commentLinks.size());
List<FindReplace> safe = new ArrayList<>(commentLinks.size());
List<PatternError> bad = new ArrayList<PatternError>();
List<PatternError> bad = new ArrayList<>();
for (FindReplace r : commentLinks) {
try {
buf.replaceAll(Collections.singletonList(r));

View File

@ -29,11 +29,11 @@ import java.util.List;
*/
public class MorphingTabPanel extends TabPanel {
// Keep track of the order the widgets/texts should be in when not hidden.
private List<Widget> widgets = new ArrayList<Widget>();
private List<String> texts = new ArrayList<String>();
private List<Widget> widgets = new ArrayList<>();
private List<String> texts = new ArrayList<>();
// currently visible widgets
private List<Widget> visibles = new ArrayList<Widget>();
private List<Widget> visibles = new ArrayList<>();
private int selection;

View File

@ -46,7 +46,7 @@ public class OnEditEnabler implements KeyPressHandler, KeyDownHandler,
MouseUpHandler, ChangeHandler, ValueChangeHandler<Object> {
private final FocusWidget widget;
private Map<TextBoxBase, String> strings = new HashMap<TextBoxBase, String>();
private Map<TextBoxBase, String> strings = new HashMap<>();
private String originalValue;

View File

@ -60,7 +60,7 @@ public class ParentProjectBox extends Composite {
}
private static class ParentProjectNameSuggestOracle extends ProjectNameSuggestOracle {
private Set<String> exclude = new HashSet<String>();
private Set<String> exclude = new HashSet<>();
public void setProject(Project.NameKey project) {
exclude.clear();
@ -85,7 +85,7 @@ public class ParentProjectBox extends Composite {
public void onSuggestionsReady(Request request, Response response) {
if (exclude.size() > 0) {
Set<Suggestion> filteredSuggestions =
new HashSet<Suggestion>(response.getSuggestions());
new HashSet<>(response.getSuggestions());
for (Suggestion s : response.getSuggestions()) {
if (exclude.contains(s.getReplacementString())) {
filteredSuggestions.remove(s);

View File

@ -39,8 +39,7 @@ public class ReviewerSuggestOracle extends SuggestAfterTypingNCharsOracle {
req.getLimit(), new GerritCallback<List<ReviewerInfo>>() {
public void onSuccess(final List<ReviewerInfo> result) {
final List<ReviewerSuggestion> r =
new ArrayList<ReviewerSuggestion>(result
.size());
new ArrayList<>(result.size());
for (final ReviewerInfo reviewer : result) {
r.add(new ReviewerSuggestion(reviewer));
}

View File

@ -58,9 +58,9 @@ public class ModeInjector {
Modes.I.xml(),
};
mimeAlias = new HashMap<String, String>();
mimeModes = new HashMap<String, String>();
modeUris = new HashMap<String, SafeUri>();
mimeAlias = new HashMap<>();
mimeModes = new HashMap<>();
modeUris = new HashMap<>();
for (DataResource m : all) {
modeUris.put(m.getName(), m.getSafeUri());
@ -103,7 +103,7 @@ public class ModeInjector {
private static native JsArrayString getDependencies(String n)
/*-{ return $wnd.CodeMirror.modes[n].dependencies || []; }-*/;
private final Set<String> loading = new HashSet<String>(4);
private final Set<String> loading = new HashSet<>(4);
private int pending;
private AsyncCallback<Void> appCallback;

View File

@ -49,7 +49,7 @@ public class EditDeserializer implements JsonDeserializer<Edit>,
return new Edit(get(o, 0), get(o, 1), get(o, 2), get(o, 3));
}
List<Edit> l = new ArrayList<Edit>((cnt / 4) - 1);
List<Edit> l = new ArrayList<>((cnt / 4) - 1);
for (int i = 4; i < cnt;) {
int as = get(o, i++);
int ae = get(o, i++);

View File

@ -35,7 +35,7 @@ public class Edit_JsonSerializer extends JsonSerializer<Edit> {
return new Edit(get(o, 0), get(o, 1), get(o, 2), get(o, 3));
}
List<Edit> l = new ArrayList<Edit>((cnt / 4) - 1);
List<Edit> l = new ArrayList<>((cnt / 4) - 1);
for (int i = 4; i < cnt;) {
int as = get(o, i++);
int ae = get(o, i++);