Commit 38bd70ae authored by Karsten Loesing's avatar Karsten Loesing
Browse files

Use diamond operator.

parent c9aadac0
...@@ -76,7 +76,7 @@ public class DetailsDocument extends Document { ...@@ -76,7 +76,7 @@ public class DetailsDocument extends Document {
} }
public List<String> getExitAddresses() { public List<String> getExitAddresses() {
return this.exitAddresses == null ? new ArrayList<String>() return this.exitAddresses == null ? new ArrayList<>()
: this.exitAddresses; : this.exitAddresses;
} }
......
...@@ -248,7 +248,7 @@ public class DetailsStatus extends Document { ...@@ -248,7 +248,7 @@ public class DetailsStatus extends Document {
} }
public SortedSet<String> getOrAddressesAndPorts() { public SortedSet<String> getOrAddressesAndPorts() {
return this.orAddressesAndPorts == null ? new TreeSet<String>() : return this.orAddressesAndPorts == null ? new TreeSet<>() :
this.orAddressesAndPorts; this.orAddressesAndPorts;
} }
......
...@@ -182,7 +182,7 @@ public class NodeStatus extends Document { ...@@ -182,7 +182,7 @@ public class NodeStatus extends Document {
} }
public SortedSet<String> getOrAddressesAndPorts() { public SortedSet<String> getOrAddressesAndPorts() {
return this.orAddressesAndPorts == null ? new TreeSet<String>() return this.orAddressesAndPorts == null ? new TreeSet<>()
: this.orAddressesAndPorts; : this.orAddressesAndPorts;
} }
......
...@@ -211,7 +211,7 @@ public class NodeIndexer implements ServletContextListener, Runnable { ...@@ -211,7 +211,7 @@ public class NodeIndexer implements ServletContextListener, Runnable {
} }
if (!newRelaysByCountryCode.containsKey(countryCode)) { if (!newRelaysByCountryCode.containsKey(countryCode)) {
newRelaysByCountryCode.put(countryCode, newRelaysByCountryCode.put(countryCode,
new HashSet<String>()); new HashSet<>());
} }
newRelaysByCountryCode.get(countryCode).add(fingerprint); newRelaysByCountryCode.get(countryCode).add(fingerprint);
newRelaysByCountryCode.get(countryCode).add(hashedFingerprint); newRelaysByCountryCode.get(countryCode).add(hashedFingerprint);
...@@ -226,7 +226,7 @@ public class NodeIndexer implements ServletContextListener, Runnable { ...@@ -226,7 +226,7 @@ public class NodeIndexer implements ServletContextListener, Runnable {
asNumber = "AS0"; asNumber = "AS0";
} }
if (!newRelaysByAsNumber.containsKey(asNumber)) { if (!newRelaysByAsNumber.containsKey(asNumber)) {
newRelaysByAsNumber.put(asNumber, new HashSet<String>()); newRelaysByAsNumber.put(asNumber, new HashSet<>());
} }
newRelaysByAsNumber.get(asNumber).add(fingerprint); newRelaysByAsNumber.get(asNumber).add(fingerprint);
newRelaysByAsNumber.get(asNumber).add(hashedFingerprint); newRelaysByAsNumber.get(asNumber).add(hashedFingerprint);
...@@ -239,7 +239,7 @@ public class NodeIndexer implements ServletContextListener, Runnable { ...@@ -239,7 +239,7 @@ public class NodeIndexer implements ServletContextListener, Runnable {
for (String flag : entry.getRelayFlags()) { for (String flag : entry.getRelayFlags()) {
String flagLowerCase = flag.toLowerCase(); String flagLowerCase = flag.toLowerCase();
if (!newRelaysByFlag.containsKey(flagLowerCase)) { if (!newRelaysByFlag.containsKey(flagLowerCase)) {
newRelaysByFlag.put(flagLowerCase, new HashSet<String>()); newRelaysByFlag.put(flagLowerCase, new HashSet<>());
} }
newRelaysByFlag.get(flagLowerCase).add(fingerprint); newRelaysByFlag.get(flagLowerCase).add(fingerprint);
newRelaysByFlag.get(flagLowerCase).add(hashedFingerprint); newRelaysByFlag.get(flagLowerCase).add(hashedFingerprint);
...@@ -260,7 +260,7 @@ public class NodeIndexer implements ServletContextListener, Runnable { ...@@ -260,7 +260,7 @@ public class NodeIndexer implements ServletContextListener, Runnable {
- entry.getFirstSeenMillis()) / ONE_DAY); - entry.getFirstSeenMillis()) / ONE_DAY);
if (!newRelaysByFirstSeenDays.containsKey(daysSinceFirstSeen)) { if (!newRelaysByFirstSeenDays.containsKey(daysSinceFirstSeen)) {
newRelaysByFirstSeenDays.put(daysSinceFirstSeen, newRelaysByFirstSeenDays.put(daysSinceFirstSeen,
new HashSet<String>()); new HashSet<>());
} }
newRelaysByFirstSeenDays.get(daysSinceFirstSeen).add(fingerprint); newRelaysByFirstSeenDays.get(daysSinceFirstSeen).add(fingerprint);
newRelaysByFirstSeenDays.get(daysSinceFirstSeen).add( newRelaysByFirstSeenDays.get(daysSinceFirstSeen).add(
...@@ -270,21 +270,21 @@ public class NodeIndexer implements ServletContextListener, Runnable { ...@@ -270,21 +270,21 @@ public class NodeIndexer implements ServletContextListener, Runnable {
- entry.getLastSeenMillis()) / ONE_DAY); - entry.getLastSeenMillis()) / ONE_DAY);
if (!newRelaysByLastSeenDays.containsKey(daysSinceLastSeen)) { if (!newRelaysByLastSeenDays.containsKey(daysSinceLastSeen)) {
newRelaysByLastSeenDays.put(daysSinceLastSeen, newRelaysByLastSeenDays.put(daysSinceLastSeen,
new HashSet<String>()); new HashSet<>());
} }
newRelaysByLastSeenDays.get(daysSinceLastSeen).add(fingerprint); newRelaysByLastSeenDays.get(daysSinceLastSeen).add(fingerprint);
newRelaysByLastSeenDays.get(daysSinceLastSeen).add( newRelaysByLastSeenDays.get(daysSinceLastSeen).add(
hashedFingerprint); hashedFingerprint);
String contact = entry.getContact(); String contact = entry.getContact();
if (!newRelaysByContact.containsKey(contact)) { if (!newRelaysByContact.containsKey(contact)) {
newRelaysByContact.put(contact, new HashSet<String>()); newRelaysByContact.put(contact, new HashSet<>());
} }
newRelaysByContact.get(contact).add(fingerprint); newRelaysByContact.get(contact).add(fingerprint);
newRelaysByContact.get(contact).add(hashedFingerprint); newRelaysByContact.get(contact).add(hashedFingerprint);
String version = entry.getVersion(); String version = entry.getVersion();
if (null != version) { if (null != version) {
if (!newRelaysByVersion.containsKey(version)) { if (!newRelaysByVersion.containsKey(version)) {
newRelaysByVersion.put(version, new HashSet<String>()); newRelaysByVersion.put(version, new HashSet<>());
} }
newRelaysByVersion.get(version).add(fingerprint); newRelaysByVersion.get(version).add(fingerprint);
newRelaysByVersion.get(version).add(hashedFingerprint); newRelaysByVersion.get(version).add(hashedFingerprint);
...@@ -347,7 +347,7 @@ public class NodeIndexer implements ServletContextListener, Runnable { ...@@ -347,7 +347,7 @@ public class NodeIndexer implements ServletContextListener, Runnable {
for (String flag : entry.getRelayFlags()) { for (String flag : entry.getRelayFlags()) {
String flagLowerCase = flag.toLowerCase(); String flagLowerCase = flag.toLowerCase();
if (!newBridgesByFlag.containsKey(flagLowerCase)) { if (!newBridgesByFlag.containsKey(flagLowerCase)) {
newBridgesByFlag.put(flagLowerCase, new HashSet<String>()); newBridgesByFlag.put(flagLowerCase, new HashSet<>());
} }
newBridgesByFlag.get(flagLowerCase).add(hashedFingerprint); newBridgesByFlag.get(flagLowerCase).add(hashedFingerprint);
newBridgesByFlag.get(flagLowerCase).add( newBridgesByFlag.get(flagLowerCase).add(
...@@ -358,7 +358,7 @@ public class NodeIndexer implements ServletContextListener, Runnable { ...@@ -358,7 +358,7 @@ public class NodeIndexer implements ServletContextListener, Runnable {
- entry.getFirstSeenMillis()) / ONE_DAY); - entry.getFirstSeenMillis()) / ONE_DAY);
if (!newBridgesByFirstSeenDays.containsKey(daysSinceFirstSeen)) { if (!newBridgesByFirstSeenDays.containsKey(daysSinceFirstSeen)) {
newBridgesByFirstSeenDays.put(daysSinceFirstSeen, newBridgesByFirstSeenDays.put(daysSinceFirstSeen,
new HashSet<String>()); new HashSet<>());
} }
newBridgesByFirstSeenDays.get(daysSinceFirstSeen).add( newBridgesByFirstSeenDays.get(daysSinceFirstSeen).add(
hashedFingerprint); hashedFingerprint);
...@@ -369,7 +369,7 @@ public class NodeIndexer implements ServletContextListener, Runnable { ...@@ -369,7 +369,7 @@ public class NodeIndexer implements ServletContextListener, Runnable {
- entry.getLastSeenMillis()) / ONE_DAY); - entry.getLastSeenMillis()) / ONE_DAY);
if (!newBridgesByLastSeenDays.containsKey(daysSinceLastSeen)) { if (!newBridgesByLastSeenDays.containsKey(daysSinceLastSeen)) {
newBridgesByLastSeenDays.put(daysSinceLastSeen, newBridgesByLastSeenDays.put(daysSinceLastSeen,
new HashSet<String>()); new HashSet<>());
} }
newBridgesByLastSeenDays.get(daysSinceLastSeen).add( newBridgesByLastSeenDays.get(daysSinceLastSeen).add(
hashedFingerprint); hashedFingerprint);
......
...@@ -116,7 +116,7 @@ public class ClientsStatusUpdater implements DescriptorListener, ...@@ -116,7 +116,7 @@ public class ClientsStatusUpdater implements DescriptorListener,
responsesByTransport, responsesByVersion); responsesByTransport, responsesByVersion);
if (!this.newResponses.containsKey(hashedFingerprint)) { if (!this.newResponses.containsKey(hashedFingerprint)) {
this.newResponses.put(hashedFingerprint, this.newResponses.put(hashedFingerprint,
new TreeSet<ClientsHistory>()); new TreeSet<>());
} }
this.newResponses.get(hashedFingerprint).add( this.newResponses.get(hashedFingerprint).add(
newResponseHistory); newResponseHistory);
......
...@@ -83,7 +83,7 @@ public class DescriptorSource { ...@@ -83,7 +83,7 @@ public class DescriptorSource {
DescriptorType descriptorType) { DescriptorType descriptorType) {
if (!this.descriptorListeners.containsKey(descriptorType)) { if (!this.descriptorListeners.containsKey(descriptorType)) {
this.descriptorListeners.put(descriptorType, this.descriptorListeners.put(descriptorType,
new HashSet<DescriptorListener>()); new HashSet<>());
} }
this.descriptorListeners.get(descriptorType).add(listener); this.descriptorListeners.get(descriptorType).add(listener);
} }
......
...@@ -224,7 +224,7 @@ public class NodeDetailsStatusUpdater implements DescriptorListener, ...@@ -224,7 +224,7 @@ public class NodeDetailsStatusUpdater implements DescriptorListener,
continue; continue;
} }
if (!this.exitListEntries.containsKey(fingerprint)) { if (!this.exitListEntries.containsKey(fingerprint)) {
this.exitListEntries.put(fingerprint, new HashMap<String, Long>()); this.exitListEntries.put(fingerprint, new HashMap<>());
} }
String exitAddress = exitAddressScanMillis.getKey(); String exitAddress = exitAddressScanMillis.getKey();
if (!this.exitListEntries.get(fingerprint).containsKey( if (!this.exitListEntries.get(fingerprint).containsKey(
......
...@@ -91,7 +91,7 @@ class RdnsLookupRequest extends Thread { ...@@ -91,7 +91,7 @@ class RdnsLookupRequest extends Thread {
envProps.put(Context.INITIAL_CONTEXT_FACTORY, envProps.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.dns.DnsContextFactory"); "com.sun.jndi.dns.DnsContextFactory");
final DirContext dnsContext = new InitialDirContext(envProps); final DirContext dnsContext = new InitialDirContext(envProps);
Set<String> results = new TreeSet<String>(); Set<String> results = new TreeSet<>();
Attributes dnsEntries = Attributes dnsEntries =
dnsContext.getAttributes(hostName, new String[] { type }); dnsContext.getAttributes(hostName, new String[] { type });
if (dnsEntries != null) { if (dnsEntries != null) {
......
...@@ -105,7 +105,7 @@ public class UptimeStatusUpdater implements DescriptorListener, ...@@ -105,7 +105,7 @@ public class UptimeStatusUpdater implements DescriptorListener,
String fingerprint = entry.getFingerprint(); String fingerprint = entry.getFingerprint();
if (!this.newRunningRelays.containsKey(fingerprint)) { if (!this.newRunningRelays.containsKey(fingerprint)) {
this.newRunningRelays.put(fingerprint, this.newRunningRelays.put(fingerprint,
new TreeMap<Long, Flags>()); new TreeMap<>());
} }
this.newRunningRelays.get(fingerprint).put(dateHourMillis, this.newRunningRelays.get(fingerprint).put(dateHourMillis,
new Flags(entry.getFlags())); new Flags(entry.getFlags()));
...@@ -125,7 +125,7 @@ public class UptimeStatusUpdater implements DescriptorListener, ...@@ -125,7 +125,7 @@ public class UptimeStatusUpdater implements DescriptorListener,
/ DateTimeHelper.ONE_HOUR) * DateTimeHelper.ONE_HOUR; / DateTimeHelper.ONE_HOUR) * DateTimeHelper.ONE_HOUR;
for (String fingerprint : fingerprints) { for (String fingerprint : fingerprints) {
if (!this.newRunningBridges.containsKey(fingerprint)) { if (!this.newRunningBridges.containsKey(fingerprint)) {
this.newRunningBridges.put(fingerprint, new TreeSet<Long>()); this.newRunningBridges.put(fingerprint, new TreeSet<>());
} }
this.newRunningBridges.get(fingerprint).add(dateHourMillis); this.newRunningBridges.get(fingerprint).add(dateHourMillis);
} }
......
...@@ -20,7 +20,7 @@ public class DummyDocumentStore extends DocumentStore { ...@@ -20,7 +20,7 @@ public class DummyDocumentStore extends DocumentStore {
private <T extends Document> SortedMap<String, Document> private <T extends Document> SortedMap<String, Document>
getStoredDocumentsByClass(Class<T> documentType) { getStoredDocumentsByClass(Class<T> documentType) {
if (!this.storedDocuments.containsKey(documentType)) { if (!this.storedDocuments.containsKey(documentType)) {
this.storedDocuments.put(documentType, new TreeMap<String, Document>()); this.storedDocuments.put(documentType, new TreeMap<>());
} }
return this.storedDocuments.get(documentType); return this.storedDocuments.get(documentType);
} }
......
...@@ -56,7 +56,7 @@ public class ResourceServletTest { ...@@ -56,7 +56,7 @@ public class ResourceServletTest {
this.requestUri = requestUri; this.requestUri = requestUri;
this.queryString = queryString; this.queryString = queryString;
this.parameterMap = parameterMap == null this.parameterMap = parameterMap == null
? new HashMap<String, String[]>() : parameterMap; ? new HashMap<>() : parameterMap;
} }
@Override @Override
...@@ -162,8 +162,8 @@ public class ResourceServletTest { ...@@ -162,8 +162,8 @@ public class ResourceServletTest {
"Running", "V2Dir", "Valid" })), 1140L, "us", "Running", "V2Dir", "Valid" })), 1140L, "us",
DateTimeHelper.parse("2013-04-16 18:00:00"), "AS7922", DateTimeHelper.parse("2013-04-16 18:00:00"), "AS7922",
"comcast cable communications, llc", null, "comcast cable communications, llc", null,
new TreeSet<String>(Arrays.asList(new String[] { new TreeSet<>(Arrays.asList(new String[]{
"000C5F55BD4814B917CC474BD537F1A3B33CCE2A" })), "000C5F55BD4814B917CC474BD537F1A3B33CCE2A"})),
new TreeSet<>(Arrays.asList(new String[] { new TreeSet<>(Arrays.asList(new String[] {
"000C5F55BD4814B917CC474BD537F1A3B33CCE2A" })), null, null, "000C5F55BD4814B917CC474BD537F1A3B33CCE2A" })), null, null,
new TreeSet<>(Arrays.asList( new TreeSet<>(Arrays.asList(
...@@ -182,7 +182,7 @@ public class ResourceServletTest { ...@@ -182,7 +182,7 @@ public class ResourceServletTest {
"liberty global operations b.v.", "liberty global operations b.v.",
"1024d/51e2a1c7 \"steven j. murdoch\" " "1024d/51e2a1c7 \"steven j. murdoch\" "
+ "<tor+steven.murdoch@cl.cam.ac.uk> <fb-token:5sr_k_zs2wm=>", + "<tor+steven.murdoch@cl.cam.ac.uk> <fb-token:5sr_k_zs2wm=>",
new TreeSet<String>(), new TreeSet<String>(), "0.2.3.24-rc-dev", new TreeSet<>(), new TreeSet<>(), "0.2.3.24-rc-dev",
"windows xp", null, null, false); "windows xp", null, null, false);
this.relays.put("0025C136C1F3A9EEFE2AE3F918F03BFA21B5070B", this.relays.put("0025C136C1F3A9EEFE2AE3F918F03BFA21B5070B",
relayTimMayTribute); relayTimMayTribute);
...@@ -337,7 +337,7 @@ public class ResourceServletTest { ...@@ -337,7 +337,7 @@ public class ResourceServletTest {
String[] parameterParts = parameter.split("="); String[] parameterParts = parameter.split("=");
if (!parameterLists.containsKey(parameterParts[0])) { if (!parameterLists.containsKey(parameterParts[0])) {
parameterLists.put(parameterParts[0], parameterLists.put(parameterParts[0],
new ArrayList<String>()); new ArrayList<>());
} }
parameterLists.get(parameterParts[0]).add(parameterParts[1]); parameterLists.get(parameterParts[0]).add(parameterParts[1]);
} }
......
...@@ -32,7 +32,7 @@ public class DummyDescriptorSource extends DescriptorSource { ...@@ -32,7 +32,7 @@ public class DummyDescriptorSource extends DescriptorSource {
private Set<Descriptor> getDescriptorsByType( private Set<Descriptor> getDescriptorsByType(
DescriptorType descriptorType) { DescriptorType descriptorType) {
if (!this.descriptors.containsKey(descriptorType)) { if (!this.descriptors.containsKey(descriptorType)) {
this.descriptors.put(descriptorType, new HashSet<Descriptor>()); this.descriptors.put(descriptorType, new HashSet<>());
} }
return this.descriptors.get(descriptorType); return this.descriptors.get(descriptorType);
} }
...@@ -45,7 +45,7 @@ public class DummyDescriptorSource extends DescriptorSource { ...@@ -45,7 +45,7 @@ public class DummyDescriptorSource extends DescriptorSource {
DescriptorType descriptorType) { DescriptorType descriptorType) {
if (!this.descriptorListeners.containsKey(descriptorType)) { if (!this.descriptorListeners.containsKey(descriptorType)) {
this.descriptorListeners.put(descriptorType, this.descriptorListeners.put(descriptorType,
new HashSet<DescriptorListener>()); new HashSet<>());
} }
this.descriptorListeners.get(descriptorType).add(listener); this.descriptorListeners.get(descriptorType).add(listener);
} }
......
...@@ -234,19 +234,19 @@ public class LookupServiceTest { ...@@ -234,19 +234,19 @@ public class LookupServiceTest {
@Test() @Test()
public void testLookupNoBlocksLines() { public void testLookupNoBlocksLines() {
this.assertLookupResult(new ArrayList<String>(), null, null, this.assertLookupResult(new ArrayList<>(), null, null,
"8.8.8.8", null, null, null, null, null, null, null, null); "8.8.8.8", null, null, null, null, null, null, null, null);
} }
@Test() @Test()
public void testLookupNoLocationLines() { public void testLookupNoLocationLines() {
this.assertLookupResult(null, new ArrayList<String>(), null, this.assertLookupResult(null, new ArrayList<>(), null,
"8.8.8.8", null, null, null, null, null, null, null, null); "8.8.8.8", null, null, null, null, null, null, null, null);
} }
@Test() @Test()
public void testLookupNoGeoipAsNum2Lines() { public void testLookupNoGeoipAsNum2Lines() {
this.assertLookupResult(null, null, new ArrayList<String>(), this.assertLookupResult(null, null, new ArrayList<>(),
"8.8.8.8", null, null, null, null, null, null, null, null); "8.8.8.8", null, null, null, null, null, null, null, null);
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment