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

This commit is contained in:
Shawn Pearce 2014-01-27 23:58:08 +00:00 committed by Gerrit Code Review
commit c6f7459d92
74 changed files with 194 additions and 214 deletions

View File

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

View File

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

View File

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

View File

@ -30,7 +30,7 @@ import java.util.Set;
public class ApprovalDetail { public class ApprovalDetail {
public static List<ApprovalDetail> sort(Collection<ApprovalDetail> ads, public static List<ApprovalDetail> sort(Collection<ApprovalDetail> ads,
final int owner) { final int owner) {
List<ApprovalDetail> sorted = new ArrayList<ApprovalDetail>(ads); List<ApprovalDetail> sorted = new ArrayList<>(ads);
Collections.sort(sorted, new Comparator<ApprovalDetail>() { Collections.sort(sorted, new Comparator<ApprovalDetail>() {
public int compare(ApprovalDetail o1, ApprovalDetail o2) { public int compare(ApprovalDetail o1, ApprovalDetail o2) {
int byOwner = (o2.account.get() == owner ? 1 : 0) int byOwner = (o2.account.get() == owner ? 1 : 0)
@ -56,7 +56,7 @@ public class ApprovalDetail {
public ApprovalDetail(final Account.Id id) { public ApprovalDetail(final Account.Id id) {
account = id; account = id;
approvals = new ArrayList<PatchSetApproval>(); approvals = new ArrayList<>();
} }
public Account.Id getAccount() { public Account.Id getAccount() {
@ -73,7 +73,7 @@ public class ApprovalDetail {
public void approved(String label) { public void approved(String label) {
if (approved == null) { if (approved == null) {
approved = new HashSet<String>(); approved = new HashSet<>();
} }
approved.add(label); approved.add(label);
hasNonZero = 1; hasNonZero = 1;
@ -81,7 +81,7 @@ public class ApprovalDetail {
public void rejected(String label) { public void rejected(String label) {
if (rejected == null) { if (rejected == null) {
rejected = new HashSet<String>(); rejected = new HashSet<>();
} }
rejected.add(label); rejected.add(label);
hasNonZero = 1; hasNonZero = 1;
@ -89,14 +89,14 @@ public class ApprovalDetail {
public void votable(String label) { public void votable(String label) {
if (votable == null) { if (votable == null) {
votable = new HashSet<String>(); votable = new HashSet<>();
} }
votable.add(label); votable.add(label);
} }
public void value(String label, int value) { public void value(String label, int value) {
if (values == null) { if (values == null) {
values = new HashMap<String, Integer>(); values = new HashMap<>();
} }
values.put(label, value); values.put(label, value);
if (value != 0) { 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>> forA;
private transient Map<Integer, List<PatchLineComment>> forB; private transient Map<Integer, List<PatchLineComment>> forB;
public CommentDetail(final PatchSet.Id idA, final PatchSet.Id idB) { public CommentDetail(PatchSet.Id idA, PatchSet.Id idB) {
this.a = new ArrayList<PatchLineComment>(); this.a = new ArrayList<>();
this.b = new ArrayList<PatchLineComment>(); this.b = new ArrayList<>();
this.idA = idA; this.idA = idA;
this.idB = idB; 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 // 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 // click Reply on the same comment at the same time). Such comments will be displayed under
// their correct parent in chronological order. // 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 // It's possible to have more than one root comment if two reviewers create a comment on the
// same line at the same time // 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 // Store all the comments in parentMap, keyed by their parent
for (PatchLineComment c : comments) { for (PatchLineComment c : comments) {
String parentUuid = c.getParentUuid(); String parentUuid = c.getParentUuid();
List<PatchLineComment> l = parentMap.get(parentUuid); List<PatchLineComment> l = parentMap.get(parentUuid);
if (l == null) { if (l == null) {
l = new ArrayList<PatchLineComment>(); l = new ArrayList<>();
parentMap.put(parentUuid, l); parentMap.put(parentUuid, l);
} }
l.add(c); 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 // 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 // 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); addChildren(parentMap, rootComments, result);
return result; return result;
@ -161,14 +161,12 @@ public class CommentDetail {
} }
private Map<Integer, List<PatchLineComment>> index( private Map<Integer, List<PatchLineComment>> index(
final List<PatchLineComment> in) { List<PatchLineComment> in) {
final HashMap<Integer, List<PatchLineComment>> r; HashMap<Integer, List<PatchLineComment>> r = new HashMap<>();
r = new HashMap<Integer, List<PatchLineComment>>();
for (final PatchLineComment p : in) { for (final PatchLineComment p : in) {
List<PatchLineComment> l = r.get(p.getLine()); List<PatchLineComment> l = r.get(p.getLine());
if (l == null) { if (l == null) {
l = new ArrayList<PatchLineComment>(); l = new ArrayList<>();
r.put(p.getLine(), l); r.put(p.getLine(), l);
} }
l.add(p); l.add(p);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -87,8 +87,7 @@ public class MyWatchesTable extends FancyFlexTable<AccountProjectWatchInfo> {
} }
protected Set<AccountProjectWatch.Key> getCheckedIds() { protected Set<AccountProjectWatch.Key> getCheckedIds() {
final Set<AccountProjectWatch.Key> ids = final Set<AccountProjectWatch.Key> ids = new HashSet<>();
new HashSet<AccountProjectWatch.Key>();
for (int row = 1; row < table.getRowCount(); row++) { for (int row = 1; row < table.getRowCount(); row++) {
final AccountProjectWatchInfo k = getRowItem(row); final AccountProjectWatchInfo k = getRowItem(row);
if (k != null && ((CheckBox) table.getWidget(row, 1)).getValue()) { 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>() { Util.ACCOUNT_SVC.myAgreements(new GerritCallback<AgreementInfo>() {
public void onSuccess(AgreementInfo result) { public void onSuccess(AgreementInfo result) {
if (isAttached()) { if (isAttached()) {
mySigned = new HashSet<String>(result.accepted); mySigned = new HashSet<>(result.accepted);
postRPC(); postRPC();
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -45,7 +45,7 @@ abstract class UpdateAvailableBar extends Composite {
} }
void set(List<MessageInfo> newMessages, Timestamp newTime) { void set(List<MessageInfo> newMessages, Timestamp newTime) {
HashSet<Integer> seen = new HashSet<Integer>(); HashSet<Integer> seen = new HashSet<>();
StringBuilder r = new StringBuilder(); StringBuilder r = new StringBuilder();
for (MessageInfo m : newMessages) { for (MessageInfo m : newMessages) {
int a = m.author() != null ? m.author()._account_id() : 0; 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; private Map<Integer, Integer> rows;
public ApprovalTable() { public ApprovalTable() {
rows = new HashMap<Integer, Integer>(); rows = new HashMap<>();
table = new Grid(1, 3); table = new Grid(1, 3);
table.addStyleName(Gerrit.RESOURCES.css().infoTable()); table.addStyleName(Gerrit.RESOURCES.css().infoTable());
@ -138,10 +138,8 @@ public class ApprovalTable extends Composite {
void display(ChangeInfo change) { void display(ChangeInfo change) {
lastChange = change; lastChange = change;
reviewerSuggestOracle.setChange(change.legacy_id()); reviewerSuggestOracle.setChange(change.legacy_id());
Map<Integer, ApprovalDetail> byUser = Map<Integer, ApprovalDetail> byUser = new LinkedHashMap<>();
new LinkedHashMap<Integer, ApprovalDetail>(); Map<Integer, AccountInfo> accounts = new LinkedHashMap<>();
Map<Integer, AccountInfo> accounts =
new LinkedHashMap<Integer, AccountInfo>();
List<String> missingLabels = initLabels(change, accounts, byUser); List<String> missingLabels = initLabels(change, accounts, byUser);
removeAllChildren(missing.getElement()); removeAllChildren(missing.getElement());
@ -152,7 +150,7 @@ public class ApprovalTable extends Composite {
if (byUser.isEmpty()) { if (byUser.isEmpty()) {
table.setVisible(false); table.setVisible(false);
} else { } else {
List<String> labels = new ArrayList<String>(change.labels()); List<String> labels = new ArrayList<>(change.labels());
Collections.sort(labels); Collections.sort(labels);
displayHeader(labels); displayHeader(labels);
table.resizeRows(1 + byUser.size()); table.resizeRows(1 + byUser.size());
@ -187,7 +185,7 @@ public class ApprovalTable extends Composite {
private Set<Integer> removableReviewers(ChangeInfo change) { private Set<Integer> removableReviewers(ChangeInfo change) {
Set<Integer> result = 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++) { for (int i = 0; i < change.removable_reviewers().length(); i++) {
result.add(change.removable_reviewers().get(i)._account_id()); result.add(change.removable_reviewers().get(i)._account_id());
} }
@ -198,7 +196,7 @@ public class ApprovalTable extends Composite {
Map<Integer, AccountInfo> accounts, Map<Integer, AccountInfo> accounts,
Map<Integer, ApprovalDetail> byUser) { Map<Integer, ApprovalDetail> byUser) {
Set<Integer> removableReviewers = removableReviewers(change); Set<Integer> removableReviewers = removableReviewers(change);
List<String> missing = new ArrayList<String>(); List<String> missing = new ArrayList<>();
for (String name : change.labels()) { for (String name : change.labels()) {
LabelInfo label = change.label(name); 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 */ /** A Cache to store common client side data by change */
public class ChangeCache { public class ChangeCache {
private static Map<Change.Id, ChangeCache> caches = private static Map<Change.Id, ChangeCache> caches = new HashMap<>();
new HashMap<Change.Id, ChangeCache>();
public static ChangeCache get(Change.Id chg) { public static ChangeCache get(Change.Id chg) {
ChangeCache cache = caches.get(chg); ChangeCache cache = caches.get(chg);
@ -56,7 +55,7 @@ public class ChangeCache {
public ListenableValue<ChangeInfo> getChangeInfoCache() { public ListenableValue<ChangeInfo> getChangeInfoCache() {
if (info == null) { if (info == null) {
info = new ListenableValue<ChangeInfo>(); info = new ListenableValue<>();
} }
return info; return info;
} }

View File

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

View File

@ -173,7 +173,7 @@ public class ChangeInfo extends JavaScriptObject {
} }
public final SortedSet<Short> value_set() { public final SortedSet<Short> value_set() {
SortedSet<Short> values = new TreeSet<Short>(); SortedSet<Short> values = new TreeSet<>();
for (String v : values()) { for (String v : values()) {
values.add(parseValue(v)); 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())); 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_STAR, "");
table.setText(0, C_SUBJECT, Util.C.changeTableColumnSubject()); table.setText(0, C_SUBJECT, Util.C.changeTableColumnSubject());
table.setText(0, C_STATUS, Util.C.changeTableColumnStatus()); table.setText(0, C_STATUS, Util.C.changeTableColumnStatus());
@ -157,7 +157,7 @@ public class ChangeTable2 extends NavigationTable<ChangeInfo> {
} }
public void updateColumnsForLabels(ChangeList... lists) { public void updateColumnsForLabels(ChangeList... lists) {
labelNames = new ArrayList<String>(); labelNames = new ArrayList<>();
for (ChangeList list : lists) { for (ChangeList list : lists) {
for (int i = 0; i < list.length(); i++) { for (int i = 0; i < list.length(); i++) {
for (String name : list.get(i).labels()) { for (String name : list.get(i).labels()) {

View File

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

View File

@ -89,7 +89,7 @@ public class IncludedInTable extends Composite implements
} }
private List<String> toList(JsArrayString in) { private List<String> toList(JsArrayString in) {
List<String> r = new ArrayList<String>(); List<String> r = new ArrayList<>();
if (in != null) { if (in != null) {
for (int i = 0; i < in.length(); i++) { for (int i = 0; i < in.length(); i++) {
r.add(in.get(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. */ /** Supports the star icon displayed on changes and tracking the status. */
public class StarredChanges { public class StarredChanges {
private static final Event.Type<ChangeStarHandler> TYPE = private static final Event.Type<ChangeStarHandler> TYPE = new Event.Type<>();
new Event.Type<ChangeStarHandler>();
/** Handler that can receive notifications of a change's starred status. */ /** Handler that can receive notifications of a change's starred status. */
public static interface ChangeStarHandler { public static interface ChangeStarHandler {
@ -118,7 +117,7 @@ public class StarredChanges {
private static boolean busy; private static boolean busy;
private static final Map<Change.Id, Boolean> pending = private static final Map<Change.Id, Boolean> pending =
new LinkedHashMap<Change.Id, Boolean>(4); new LinkedHashMap<>(4);
private static void startRequest() { private static void startRequest() {
busy = true; busy = true;

View File

@ -60,7 +60,7 @@ public class DashboardsTable extends NavigationTable<DashboardInfo> {
} }
public void display(JsArray<DashboardList> in) { 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 (DashboardList list : Natives.asList(in)) {
for (DashboardInfo d : Natives.asList(list)) { for (DashboardInfo d : Natives.asList(list)) {
if (!map.containsKey(d.id())) { 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) { public void display(List<DashboardInfo> list) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -48,7 +48,7 @@ class SkipManager {
} }
JsArray<Region> regions = diff.content(); JsArray<Region> regions = diff.content();
List<SkippedLine> skips = new ArrayList<SkippedLine>(); List<SkippedLine> skips = new ArrayList<>();
int lineA = 0, lineB = 0; int lineA = 0, lineB = 0;
for (int i = 0; i < regions.length(); i++) { for (int i = 0; i < regions.length(); i++) {
Region current = regions.get(i); Region current = regions.get(i);
@ -78,7 +78,7 @@ class SkipManager {
CodeMirror cmA = host.getCmFromSide(DisplaySide.A); CodeMirror cmA = host.getCmFromSide(DisplaySide.A);
CodeMirror cmB = host.getCmFromSide(DisplaySide.B); CodeMirror cmB = host.getCmFromSide(DisplaySide.B);
skipBars = new HashSet<SkipBar>(); skipBars = new HashSet<>();
for (SkippedLine skip : skips) { for (SkippedLine skip : skips) {
SkipBar barA = newSkipBar(cmA, DisplaySide.A, skip); SkipBar barA = newSkipBar(cmA, DisplaySide.A, skip);
SkipBar barB = newSkipBar(cmB, DisplaySide.B, 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, public static List<DownloadUrlLink> createDownloadUrlLinks(String project,
String ref, boolean allowAnonymous) { String ref, boolean allowAnonymous) {
List<DownloadUrlLink> urls = new ArrayList<DownloadUrlLink>(); List<DownloadUrlLink> urls = new ArrayList<>();
Set<DownloadScheme> allowedSchemes = Gerrit.getConfig().getDownloadSchemes(); Set<DownloadScheme> allowedSchemes = Gerrit.getConfig().getDownloadSchemes();
if (allowAnonymous if (allowAnonymous

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -34,7 +34,7 @@ public class AccountSuggestOracle extends SuggestAfterTypingNCharsOracle {
new GerritCallback<List<AccountInfo>>() { new GerritCallback<List<AccountInfo>>() {
public void onSuccess(final List<AccountInfo> result) { public void onSuccess(final List<AccountInfo> result) {
final ArrayList<AccountSuggestion> r = final ArrayList<AccountSuggestion> r =
new ArrayList<AccountSuggestion>(result.size()); new ArrayList<>(result.size());
for (final AccountInfo p : result) { for (final AccountInfo p : result) {
r.add(new AccountSuggestion(p)); 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. // One or more of the patterns isn't valid on this browser.
// Try to filter the list down and remove the invalid ones. // 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) { for (FindReplace r : commentLinks) {
try { try {
buf.replaceAll(Collections.singletonList(r)); buf.replaceAll(Collections.singletonList(r));

View File

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

View File

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

View File

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

View File

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

View File

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