Remove unnecessary explicit generic type declarations

They can be inferred correctly even in Java 7, and display as
compiler warnings in IntelliJ.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=173451087
This commit is contained in:
mcilwain 2017-10-25 14:35:29 -07:00 committed by jianglai
parent 0fdc189e9c
commit eed2e0c45f
20 changed files with 37 additions and 46 deletions

View file

@ -73,7 +73,7 @@ public class MapreduceEntityCleanupActionTest
private final FakeClock clock = new FakeClock(DateTime.now(UTC));
private final FakeResponse response = new FakeResponse();
private static final ImmutableList<List<String>> inputStrings = ImmutableList.<List<String>>of(
private static final ImmutableList<List<String>> inputStrings = ImmutableList.of(
ImmutableList.of("a", "b", "c"),
ImmutableList.of("d", "e", "f", "g", "h"),
ImmutableList.of("i", "j", "k"),
@ -119,23 +119,19 @@ public class MapreduceEntityCleanupActionTest
}
private void setAnyJobAndDaysOld(int daysOld) {
setJobIdJobNameAndDaysOld(
Optional.<String>empty(), Optional.<String>empty(), Optional.<Integer>of(daysOld));
setJobIdJobNameAndDaysOld(Optional.empty(), Optional.empty(), Optional.of(daysOld));
}
private void setJobId(String jobId) {
setJobIdJobNameAndDaysOld(
Optional.of(jobId), Optional.<String>empty(), Optional.<Integer>empty());
setJobIdJobNameAndDaysOld(Optional.of(jobId), Optional.empty(), Optional.empty());
}
private void setJobName(String jobName) {
setJobIdJobNameAndDaysOld(
Optional.<String>empty(), Optional.of(jobName), Optional.<Integer>empty());
setJobIdJobNameAndDaysOld(Optional.empty(), Optional.of(jobName), Optional.empty());
}
private void setJobNameAndDaysOld(String jobName, int daysOld) {
setJobIdJobNameAndDaysOld(
Optional.<String>empty(), Optional.of(jobName), Optional.<Integer>of(daysOld));
setJobIdJobNameAndDaysOld(Optional.empty(), Optional.of(jobName), Optional.of(daysOld));
}
private void setJobIdJobNameAndDaysOld(
@ -144,9 +140,9 @@ public class MapreduceEntityCleanupActionTest
action = new MapreduceEntityCleanupAction(
jobId,
jobName,
Optional.<Integer>empty(), // numJobsToDelete
Optional.empty(), // numJobsToDelete
daysOld,
Optional.<Boolean>empty(), // force
Optional.empty(), // force
mapreduceEntityCleanupUtil,
clock,
DatastoreServiceFactory.getDatastoreService(),

View file

@ -284,8 +284,7 @@ public class SessionUtilsTest {
@Test
public void testHasAccessToRegistrar_accessRevoked_returnsFalse() throws Exception {
RegistrarContact.updateContacts(
loadRegistrar(DEFAULT_CLIENT_ID), new java.util.HashSet<RegistrarContact>());
RegistrarContact.updateContacts(loadRegistrar(DEFAULT_CLIENT_ID), new java.util.HashSet<>());
assertThat(SessionUtils.hasAccessToRegistrar(DEFAULT_CLIENT_ID, THE_REGISTRAR_GAE_USER_ID))
.isFalse();
}

View file

@ -62,10 +62,10 @@ public class DiffUtilsTest {
@Test
public void test_emptyToNullCollection_doesntDisplay() {
Map<String, Object> mapA = new HashMap<String, Object>();
Map<String, Object> mapA = new HashMap<>();
mapA.put("a", "jim");
mapA.put("b", null);
Map<String, Object> mapB = new HashMap<String, Object>();
Map<String, Object> mapB = new HashMap<>();
mapB.put("a", "tim");
mapB.put("b", ImmutableSet.of());
// This ensures that it is not outputting a diff of b: null -> [].

View file

@ -208,34 +208,34 @@ public class XmlTestUtils {
}
set.add(simpleEntry.getValue());
}
return new AbstractMap.SimpleEntry<String, Object>(mappedKey, set);
return new AbstractMap.SimpleEntry<>(mappedKey, set);
}
if (obj instanceof Number) {
return new AbstractMap.SimpleEntry<String, Object>(null, obj.toString());
return new AbstractMap.SimpleEntry<>(null, obj.toString());
}
if (obj instanceof Boolean) {
return new AbstractMap.SimpleEntry<String, Object>(null, ((Boolean) obj) ? "1" : "0");
return new AbstractMap.SimpleEntry<>(null, ((Boolean) obj) ? "1" : "0");
}
if (obj instanceof String) {
// Turn stringified booleans into integers. Both are acceptable as xml boolean values, but
// we use "true" and "false" whereas the samples use "1" and "0".
if (obj.equals("true")) {
return new AbstractMap.SimpleEntry<String, Object>(null, "1");
return new AbstractMap.SimpleEntry<>(null, "1");
}
if (obj.equals("false")) {
return new AbstractMap.SimpleEntry<String, Object>(null, "0");
return new AbstractMap.SimpleEntry<>(null, "0");
}
String string = obj.toString();
// We use a slightly different datetime format (both legal) than the samples, so normalize
// both into Datetime objects.
try {
return new AbstractMap.SimpleEntry<String, Object>(
return new AbstractMap.SimpleEntry<>(
null, ISODateTimeFormat.dateTime().parseDateTime(string).toDateTime(UTC));
} catch (IllegalArgumentException e) {
// It wasn't a DateTime.
}
try {
return new AbstractMap.SimpleEntry<String, Object>(
return new AbstractMap.SimpleEntry<>(
null, ISODateTimeFormat.dateTimeNoMillis().parseDateTime(string).toDateTime(UTC));
} catch (IllegalArgumentException e) {
// It wasn't a DateTime.
@ -243,12 +243,12 @@ public class XmlTestUtils {
try {
if (!InternetDomainName.isValid(string)) {
// It's not a domain name, but it is an InetAddress. Ergo, it's an ip address.
return new AbstractMap.SimpleEntry<String, Object>(null, InetAddresses.forString(string));
return new AbstractMap.SimpleEntry<>(null, InetAddresses.forString(string));
}
} catch (IllegalArgumentException e) {
// Not an ip address.
}
return new AbstractMap.SimpleEntry<String, Object>(null, string);
return new AbstractMap.SimpleEntry<>(null, string);
}
return new AbstractMap.SimpleEntry<>(null, checkNotNull(obj));
}