[tor-commits] [metrics-web/master] Use Java 7's diamond operator wherever possible.

karsten at torproject.org karsten at torproject.org
Fri Feb 24 08:58:24 UTC 2017


commit 4065d3a792b7954ee3d43a5ef52ee4d104c8df9c
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date:   Thu Feb 23 14:22:37 2017 +0100

    Use Java 7's diamond operator wherever possible.
    
    As part of this, set Java source and target version to 7 in two build
    files and add a missing library for running tests.
    
    Implements #21535.
---
 .../src/org/torproject/metrics/advbwdist/Main.java |  7 ++--
 .../src/org/torproject/metrics/clients/Main.java   |  6 ++--
 modules/connbidirect/build.xml                     |  9 ++---
 .../org/torproject/metrics/connbidirect/Main.java  | 17 ++++-----
 .../torproject/metrics/connbidirect/MainTest.java  | 35 ++++++++-----------
 .../org/torproject/metrics/hidserv/Aggregator.java |  6 ++--
 .../torproject/metrics/hidserv/DateTimeHelper.java |  2 +-
 .../torproject/metrics/hidserv/DocumentStore.java  |  5 ++-
 .../torproject/metrics/hidserv/Extrapolator.java   | 14 ++++----
 .../src/org/torproject/metrics/hidserv/Main.java   | 11 +++---
 .../src/org/torproject/metrics/hidserv/Parser.java | 20 ++++-------
 .../org/torproject/metrics/hidserv/Simulate.java   | 40 ++++++++++------------
 .../org/torproject/ernie/cron/Configuration.java   |  3 +-
 .../cron/RelayDescriptorDatabaseImporter.java      | 10 +++---
 .../cron/network/ConsensusStatsFileHandler.java    | 11 +++---
 .../ernie/cron/performance/TorperfProcessor.java   | 14 ++++----
 .../java/org/torproject/metrics/webstats/Main.java |  2 +-
 website/build.xml                                  |  4 +--
 .../src/org/torproject/metrics/web/AnyServlet.java |  2 +-
 .../torproject/metrics/web/ContentProvider.java    |  6 ++--
 .../org/torproject/metrics/web/GraphServlet.java   |  7 ++--
 .../org/torproject/metrics/web/LinkServlet.java    |  2 +-
 .../org/torproject/metrics/web/MetricServlet.java  | 25 +++++---------
 .../org/torproject/metrics/web/NewsServlet.java    |  9 +++--
 .../org/torproject/metrics/web/TableServlet.java   |  7 ++--
 .../metrics/web/graphs/BubblesServlet.java         |  2 +-
 .../torproject/metrics/web/graphs/Countries.java   |  2 +-
 .../metrics/web/graphs/GraphParameterChecker.java  |  9 +++--
 .../metrics/web/graphs/RObjectGenerator.java       | 13 ++++---
 .../metrics/web/graphs/TableParameterChecker.java  |  7 ++--
 .../metrics/web/research/ResearchStatsServlet.java |  2 +-
 31 files changed, 132 insertions(+), 177 deletions(-)

diff --git a/modules/advbwdist/src/org/torproject/metrics/advbwdist/Main.java b/modules/advbwdist/src/org/torproject/metrics/advbwdist/Main.java
index 83c4934..7d7678d 100644
--- a/modules/advbwdist/src/org/torproject/metrics/advbwdist/Main.java
+++ b/modules/advbwdist/src/org/torproject/metrics/advbwdist/Main.java
@@ -38,8 +38,7 @@ public class Main {
         + "server-descriptors"));
     Iterator<DescriptorFile> descriptorFiles =
         descriptorReader.readDescriptors();
-    Map<String, Long> serverDescriptors =
-        new HashMap<String, Long>();
+    Map<String, Long> serverDescriptors = new HashMap<>();
     while (descriptorFiles.hasNext()) {
       DescriptorFile descriptorFile = descriptorFiles.next();
       for (Descriptor descriptor : descriptorFile.getDescriptors()) {
@@ -87,8 +86,8 @@ public class Main {
             (RelayNetworkStatusConsensus) descriptor;
         String validAfter = dateTimeFormat.format(
             consensus.getValidAfterMillis());
-        List<Long> advertisedBandwidthsAllRelays = new ArrayList<Long>();
-        List<Long> advertisedBandwidthsExitsOnly = new ArrayList<Long>();
+        List<Long> advertisedBandwidthsAllRelays = new ArrayList<>();
+        List<Long> advertisedBandwidthsExitsOnly = new ArrayList<>();
         for (NetworkStatusEntry relay
             : consensus.getStatusEntries().values()) {
           if (!relay.getFlags().contains("Running")) {
diff --git a/modules/clients/src/org/torproject/metrics/clients/Main.java b/modules/clients/src/org/torproject/metrics/clients/Main.java
index c9dc004..dff73f7 100644
--- a/modules/clients/src/org/torproject/metrics/clients/Main.java
+++ b/modules/clients/src/org/torproject/metrics/clients/Main.java
@@ -297,8 +297,7 @@ public class Main {
       SortedMap<String, Integer> frequencies, long publishedMillis)
       throws IOException {
     double total = 0.0;
-    SortedMap<String, Double> frequenciesCopy =
-        new TreeMap<String, Double>();
+    SortedMap<String, Double> frequenciesCopy = new TreeMap<>();
     if (frequencies != null) {
       for (Map.Entry<String, Integer> e : frequencies.entrySet()) {
         if (e.getValue() < 4.0) {
@@ -399,8 +398,7 @@ public class Main {
     }
   }
 
-  private static Map<String, BufferedWriter> openOutputFiles =
-      new HashMap<String, BufferedWriter>();
+  private static Map<String, BufferedWriter> openOutputFiles = new HashMap<>();
 
   private static void writeOutputLine(String fingerprint, String node,
       String metric, String country, String transport, String version,
diff --git a/modules/connbidirect/build.xml b/modules/connbidirect/build.xml
index 9aaf2e1..72c028f 100644
--- a/modules/connbidirect/build.xml
+++ b/modules/connbidirect/build.xml
@@ -11,6 +11,7 @@
       <include name="commons-compress-1.9.jar"/>
       <include name="commons-lang-2.6.jar"/>
       <include name="junit4-4.11.jar"/>
+      <include name="hamcrest-all-1.3.jar"/>
       <include name="descriptor-1.4.0.jar"/>
       <include name="slf4j-api-1.7.7.jar"/>
       <include name="logback-core-1.1.2.jar"/>
@@ -22,8 +23,8 @@
     <mkdir dir="${connbidirect-classes}"/>
     <javac destdir="${connbidirect-classes}"
            srcdir="${connbidirect-sources}"
-           source="1.6"
-           target="1.6"
+           source="1.7"
+           target="1.7"
            debug="true"
            deprecation="true"
            optimize="false"
@@ -36,8 +37,8 @@
   <target name="test" depends="compile">
     <javac destdir="${connbidirect-classes}"
            srcdir="${connbidirect-tests}"
-           source="1.6"
-           target="1.6"
+           source="1.7"
+           target="1.7"
            debug="true"
            deprecation="true"
            optimize="false"
diff --git a/modules/connbidirect/src/main/java/org/torproject/metrics/connbidirect/Main.java b/modules/connbidirect/src/main/java/org/torproject/metrics/connbidirect/Main.java
index db4c640..63dc6be 100644
--- a/modules/connbidirect/src/main/java/org/torproject/metrics/connbidirect/Main.java
+++ b/modules/connbidirect/src/main/java/org/torproject/metrics/connbidirect/Main.java
@@ -148,7 +148,7 @@ public class Main {
           + "raw statistics anymore.");
       return;
     }
-    SortedSet<RawStat> newRawStats = new TreeSet<RawStat>();
+    SortedSet<RawStat> newRawStats = new TreeSet<>();
     parseHistory = addRawStatsFromDescriptors(newRawStats,
         descriptorsDirectories, parseHistory);
     if (parseHistory == null) {
@@ -231,8 +231,7 @@ public class Main {
   /* Parse a parse history. */
   static SortedMap<String, Long> parseParseHistory(
       String formattedParseHistory) {
-    SortedMap<String, Long> parsedParseHistory =
-        new TreeMap<String, Long>();
+    SortedMap<String, Long> parsedParseHistory = new TreeMap<>();
     LineNumberReader lnr = new LineNumberReader(new StringReader(
         formattedParseHistory));
     String line = "";
@@ -279,8 +278,7 @@ public class Main {
   /* Parse aggregate connbidirect stats. */
   static SortedMap<String, Short> parseAggregateStats(
       String formattedAggregatedStats) {
-    SortedMap<String, Short> parsedAggregateStats =
-        new TreeMap<String, Short>();
+    SortedMap<String, Short> parsedAggregateStats = new TreeMap<>();
     if (formattedAggregatedStats.length() < 1) {
       return parsedAggregateStats; /* Empty file. */
     }
@@ -328,7 +326,7 @@ public class Main {
 
   /* Parse raw statistics. */
   static SortedSet<RawStat> parseRawStats(String formattedRawStats) {
-    SortedSet<RawStat> parsedRawStats = new TreeSet<RawStat>();
+    SortedSet<RawStat> parsedRawStats = new TreeSet<>();
     LineNumberReader lnr = new LineNumberReader(new StringReader(
         formattedRawStats));
     String line = "";
@@ -422,8 +420,8 @@ public class Main {
   static SortedSet<Long> mergeRawStats(
       SortedSet<RawStat> rawStats, SortedSet<RawStat> newRawStats) {
     rawStats.addAll(newRawStats);
-    SortedSet<Long> discardedRawStats = new TreeSet<Long>();
-    SortedSet<Long> availableRawStats = new TreeSet<Long>();
+    SortedSet<Long> discardedRawStats = new TreeSet<>();
+    SortedSet<Long> availableRawStats = new TreeSet<>();
     for (RawStat rawStat : rawStats) {
       if (rawStat.fingerprint != null) {
         availableRawStats.add(rawStat.dateDays);
@@ -440,8 +438,7 @@ public class Main {
       SortedSet<RawStat> rawStats) {
     DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
     dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
-    SortedMap<String, List<Short>> fractionsByDateAndDirection =
-        new TreeMap<String, List<Short>>();
+    SortedMap<String, List<Short>> fractionsByDateAndDirection = new TreeMap<>();
     final String[] directions = new String[] { "read", "write", "both" };
     for (RawStat rawStat : rawStats) {
       if (rawStat.fingerprint != null) {
diff --git a/modules/connbidirect/src/test/java/org/torproject/metrics/connbidirect/MainTest.java b/modules/connbidirect/src/test/java/org/torproject/metrics/connbidirect/MainTest.java
index 92b6866..c63a772 100644
--- a/modules/connbidirect/src/test/java/org/torproject/metrics/connbidirect/MainTest.java
+++ b/modules/connbidirect/src/test/java/org/torproject/metrics/connbidirect/MainTest.java
@@ -43,14 +43,14 @@ public class MainTest {
 
   @Test
   public void testParseHistoryOneEntry() {
-    SortedMap<String, Long> parseHistory = new TreeMap<String, Long>();
+    SortedMap<String, Long> parseHistory = new TreeMap<>();
     parseHistory.put(pathA, lastmodA);
     assertParseHistoryCanBeSerializedAndDeserialized(parseHistory);
   }
 
   @Test
   public void testParseHistoryTwoEntries() {
-    SortedMap<String, Long> parseHistory = new TreeMap<String, Long>();
+    SortedMap<String, Long> parseHistory = new TreeMap<>();
     parseHistory.put(pathA, lastmodA);
     parseHistory.put(pathB, lastmodB);
     assertParseHistoryCanBeSerializedAndDeserialized(parseHistory);
@@ -95,16 +95,14 @@ public class MainTest {
 
   @Test
   public void testAggregateStatsOneEntry() {
-    SortedMap<String, Short> aggregateStats =
-        new TreeMap<String, Short>();
+    SortedMap<String, Short> aggregateStats = new TreeMap<>();
     aggregateStats.put("2015-08-18,read,0.25", (short) 42);
     assertAggregateStatsCanBeSerializedAndDeserialized(aggregateStats);
   }
 
   @Test
   public void testAggregateStatsThreeEntries() {
-    SortedMap<String, Short> aggregateStats =
-        new TreeMap<String, Short>();
+    SortedMap<String, Short> aggregateStats = new TreeMap<>();
     aggregateStats.put("2015-08-18,read,0.25", (short) 12);
     aggregateStats.put("2015-08-18,read,0.5", (short) 24);
     aggregateStats.put("2015-08-18,read,0.75", (short) 42);
@@ -138,7 +136,7 @@ public class MainTest {
 
   @Test
   public void testRawStatsOneEntry() {
-    SortedSet<Main.RawStat> rawStats = new TreeSet<Main.RawStat>();
+    SortedSet<Main.RawStat> rawStats = new TreeSet<>();
     rawStats.add(new Main.RawStat(DATE_A, FPR_A, (short) 40, (short) 30,
         (short) 50));
     assertRawStatsCanBeSerializedAndDeserialized(rawStats);
@@ -154,7 +152,7 @@ public class MainTest {
 
   @Test
   public void testMergeRawStatsAddNothing() {
-    SortedSet<Main.RawStat> rawStats = new TreeSet<Main.RawStat>();
+    SortedSet<Main.RawStat> rawStats = new TreeSet<>();
     rawStats.add(new Main.RawStat(DATE_A, FPR_A, (short) 40, (short) 30,
         (short) 50));
     assertRawStatsCanBeMerged(rawStats, new TreeSet<Main.RawStat>(),
@@ -163,10 +161,10 @@ public class MainTest {
 
   @Test
   public void testMergeRawStatsAddSame() {
-    SortedSet<Main.RawStat> rawStats = new TreeSet<Main.RawStat>();
+    SortedSet<Main.RawStat> rawStats = new TreeSet<>();
     rawStats.add(new Main.RawStat(DATE_A, FPR_A, (short) 40, (short) 30,
         (short) 50));
-    SortedSet<Main.RawStat> newRawStats = new TreeSet<Main.RawStat>();
+    SortedSet<Main.RawStat> newRawStats = new TreeSet<>();
     newRawStats.add(new Main.RawStat(DATE_A, FPR_A, (short) 40,
         (short) 30, (short) 50));
     assertRawStatsCanBeMerged(rawStats, newRawStats, false);
@@ -174,10 +172,10 @@ public class MainTest {
 
   @Test
   public void testMergeRawStatsAddOther() {
-    SortedSet<Main.RawStat> rawStats = new TreeSet<Main.RawStat>();
+    SortedSet<Main.RawStat> rawStats = new TreeSet<>();
     rawStats.add(new Main.RawStat(DATE_A, FPR_A, (short) 40, (short) 30,
         (short) 50));
-    SortedSet<Main.RawStat> newRawStats = new TreeSet<Main.RawStat>();
+    SortedSet<Main.RawStat> newRawStats = new TreeSet<>();
     newRawStats.add(new Main.RawStat(DATE_B, FPR_B, (short) 40,
         (short) 30, (short) 50));
     assertRawStatsCanBeMerged(rawStats, newRawStats, false);
@@ -216,8 +214,7 @@ public class MainTest {
   private void assertStatsCanBeAggregated(
       SortedMap<String, Short> expectedAggregateStats,
       SortedSet<Main.RawStat> rawStats) {
-    SortedMap<String, Short> updatedAggregateStats =
-        new TreeMap<String, Short>();
+    SortedMap<String, Short> updatedAggregateStats = new TreeMap<>();
     Main.updateAggregateStats(updatedAggregateStats, rawStats);
     assertEquals("Updated aggregate statistics don't match",
         expectedAggregateStats, updatedAggregateStats);
@@ -231,8 +228,7 @@ public class MainTest {
 
   @Test
   public void testUpdateAggregateStatsSingleRawStat() {
-    SortedMap<String, Short> expectedAggregateStats =
-        new TreeMap<String, Short>();
+    SortedMap<String, Short> expectedAggregateStats = new TreeMap<>();
     expectedAggregateStats.put("2015-08-18,read,0.25", (short) 42);
     expectedAggregateStats.put("2015-08-18,read,0.5", (short) 42);
     expectedAggregateStats.put("2015-08-18,read,0.75", (short) 42);
@@ -242,7 +238,7 @@ public class MainTest {
     expectedAggregateStats.put("2015-08-18,both,0.25", (short) 22);
     expectedAggregateStats.put("2015-08-18,both,0.5", (short) 22);
     expectedAggregateStats.put("2015-08-18,both,0.75", (short) 22);
-    SortedSet<Main.RawStat> rawStats = new TreeSet<Main.RawStat>();
+    SortedSet<Main.RawStat> rawStats = new TreeSet<>();
     rawStats.add(new Main.RawStat(DATE_A, FPR_A, (short) 42, (short) 32,
         (short) 22));
     assertStatsCanBeAggregated(expectedAggregateStats, rawStats);
@@ -250,8 +246,7 @@ public class MainTest {
 
   @Test
   public void testUpdateAggregateStatsTwoRawStat() {
-    SortedMap<String, Short> expectedAggregateStats =
-        new TreeMap<String, Short>();
+    SortedMap<String, Short> expectedAggregateStats = new TreeMap<>();
     expectedAggregateStats.put("2015-08-18,read,0.25", (short) 32);
     expectedAggregateStats.put("2015-08-18,read,0.5", (short) 42);
     expectedAggregateStats.put("2015-08-18,read,0.75", (short) 42);
@@ -261,7 +256,7 @@ public class MainTest {
     expectedAggregateStats.put("2015-08-18,both,0.25", (short) 12);
     expectedAggregateStats.put("2015-08-18,both,0.5", (short) 22);
     expectedAggregateStats.put("2015-08-18,both,0.75", (short) 22);
-    SortedSet<Main.RawStat> rawStats = new TreeSet<Main.RawStat>();
+    SortedSet<Main.RawStat> rawStats = new TreeSet<>();
     rawStats.add(new Main.RawStat(DATE_A, FPR_A, (short) 32, (short) 22,
         (short) 12));
     rawStats.add(new Main.RawStat(DATE_A, FPR_B, (short) 42, (short) 32,
diff --git a/modules/hidserv/src/org/torproject/metrics/hidserv/Aggregator.java b/modules/hidserv/src/org/torproject/metrics/hidserv/Aggregator.java
index 677c2ca..ea09a78 100644
--- a/modules/hidserv/src/org/torproject/metrics/hidserv/Aggregator.java
+++ b/modules/hidserv/src/org/torproject/metrics/hidserv/Aggregator.java
@@ -70,10 +70,8 @@ public class Aggregator {
      * dates, map values are double[] arrays with the extrapolated network
      * total as first element and the corresponding computed network
      * fraction as second element. */
-    SortedMap<String, List<double[]>> extrapolatedCells =
-        new TreeMap<String, List<double[]>>();
-    SortedMap<String, List<double[]>> extrapolatedOnions =
-        new TreeMap<String, List<double[]>>();
+    SortedMap<String, List<double[]>> extrapolatedCells = new TreeMap<>();
+    SortedMap<String, List<double[]>> extrapolatedOnions = new TreeMap<>();
     for (ExtrapolatedHidServStats extrapolated : extrapolatedStats) {
       String date = DateTimeHelper.format(
           extrapolated.getStatsDateMillis(),
diff --git a/modules/hidserv/src/org/torproject/metrics/hidserv/DateTimeHelper.java b/modules/hidserv/src/org/torproject/metrics/hidserv/DateTimeHelper.java
index d35fc9f..5be6800 100644
--- a/modules/hidserv/src/org/torproject/metrics/hidserv/DateTimeHelper.java
+++ b/modules/hidserv/src/org/torproject/metrics/hidserv/DateTimeHelper.java
@@ -47,7 +47,7 @@ public class DateTimeHelper {
     }
 
     protected Map<String, DateFormat> initialValue() {
-      return new HashMap<String, DateFormat>();
+      return new HashMap<>();
     }
 
     public void remove() {
diff --git a/modules/hidserv/src/org/torproject/metrics/hidserv/DocumentStore.java b/modules/hidserv/src/org/torproject/metrics/hidserv/DocumentStore.java
index ac05096..2670cf4 100644
--- a/modules/hidserv/src/org/torproject/metrics/hidserv/DocumentStore.java
+++ b/modules/hidserv/src/org/torproject/metrics/hidserv/DocumentStore.java
@@ -50,8 +50,7 @@ public class DocumentStore<T extends Document> {
     retrievedDocuments.addAll(documentsToStore);
 
     /* Serialize documents. */
-    SortedMap<String, SortedSet<String>> formattedDocuments =
-        new TreeMap<String, SortedSet<String>>();
+    SortedMap<String, SortedSet<String>> formattedDocuments = new TreeMap<>();
     for (T retrieveDocument : retrievedDocuments) {
       String[] formattedDocument = retrieveDocument.format();
       if (!formattedDocuments.containsKey(formattedDocument[0])) {
@@ -110,7 +109,7 @@ public class DocumentStore<T extends Document> {
 
     /* Check if the document file exists, and if not, return an empty set.
      * This is not an error case. */
-    Set<T> result = new HashSet<T>();
+    Set<T> result = new HashSet<>();
     if (!documentFile.exists()) {
       return result;
     }
diff --git a/modules/hidserv/src/org/torproject/metrics/hidserv/Extrapolator.java b/modules/hidserv/src/org/torproject/metrics/hidserv/Extrapolator.java
index 9dc7ba0..262720a 100644
--- a/modules/hidserv/src/org/torproject/metrics/hidserv/Extrapolator.java
+++ b/modules/hidserv/src/org/torproject/metrics/hidserv/Extrapolator.java
@@ -90,9 +90,8 @@ public class Extrapolator {
     }
 
     /* Re-arrange reported stats by fingerprint. */
-    SortedMap<String, Set<ReportedHidServStats>>
-        parsedStatsByFingerprint =
-        new TreeMap<String, Set<ReportedHidServStats>>();
+    SortedMap<String, Set<ReportedHidServStats>> parsedStatsByFingerprint =
+        new TreeMap<>();
     for (ReportedHidServStats stat : reportedStats) {
       String fingerprint = stat.getFingerprint();
       if (!parsedStatsByFingerprint.containsKey(fingerprint)) {
@@ -111,9 +110,8 @@ public class Extrapolator {
        * those that still need to be extrapolated.  Also make a list of
        * all dates for which we need to retrieve computed network
        * fractions. */
-      Set<ReportedHidServStats> newReportedStats =
-          new HashSet<ReportedHidServStats>();
-      SortedSet<String> retrieveFractionDates = new TreeSet<String>();
+      Set<ReportedHidServStats> newReportedStats = new HashSet<>();
+      SortedSet<String> retrieveFractionDates = new TreeSet<>();
       for (ReportedHidServStats stats : e.getValue()) {
 
         /* Check whether extrapolated stats already contain an object with
@@ -149,9 +147,9 @@ public class Extrapolator {
        * because we need to count known consensuses even if the relay was
        * not contained in a consensus or had a network fraction of exactly
        * zero.) */
-      SortedSet<Long> knownConsensuses = new TreeSet<Long>();
+      SortedSet<Long> knownConsensuses = new TreeSet<>();
       SortedMap<Long, ComputedNetworkFractions> computedNetworkFractions =
-          new TreeMap<Long, ComputedNetworkFractions>();
+          new TreeMap<>();
       for (String date : retrieveFractionDates) {
         File documentFile = new File(
             this.computedNetworkFractionsDirectory, date);
diff --git a/modules/hidserv/src/org/torproject/metrics/hidserv/Main.java b/modules/hidserv/src/org/torproject/metrics/hidserv/Main.java
index b729c51..ad0b415 100644
--- a/modules/hidserv/src/org/torproject/metrics/hidserv/Main.java
+++ b/modules/hidserv/src/org/torproject/metrics/hidserv/Main.java
@@ -19,7 +19,7 @@ public class Main {
   public static void main(String[] args) {
 
     /* Initialize directories and file paths. */
-    Set<File> inDirectories = new HashSet<File>();
+    Set<File> inDirectories = new HashSet<>();
     inDirectories.add(
         new File("../../shared/in/recent/relay-descriptors/consensuses"));
     inDirectories.add(
@@ -31,11 +31,9 @@ public class Main {
     System.out.println("Initializing parser and reading parse "
         + "history...");
     DocumentStore<ReportedHidServStats> reportedHidServStatsStore =
-        new DocumentStore<ReportedHidServStats>(
-        ReportedHidServStats.class);
+        new DocumentStore<>(ReportedHidServStats.class);
     DocumentStore<ComputedNetworkFractions>
-        computedNetworkFractionsStore =
-        new DocumentStore<ComputedNetworkFractions>(
+        computedNetworkFractionsStore = new DocumentStore<>(
         ComputedNetworkFractions.class);
     Parser parser = new Parser(inDirectories, statusDirectory,
         reportedHidServStatsStore, computedNetworkFractionsStore);
@@ -63,8 +61,7 @@ public class Main {
      * single relays. */
     System.out.println("Extrapolating statistics...");
     DocumentStore<ExtrapolatedHidServStats> extrapolatedHidServStatsStore
-        = new DocumentStore<ExtrapolatedHidServStats>(
-        ExtrapolatedHidServStats.class);
+        = new DocumentStore<>(ExtrapolatedHidServStats.class);
     Extrapolator extrapolator = new Extrapolator(statusDirectory,
         reportedHidServStatsStore, computedNetworkFractionsStore,
         extrapolatedHidServStatsStore);
diff --git a/modules/hidserv/src/org/torproject/metrics/hidserv/Parser.java b/modules/hidserv/src/org/torproject/metrics/hidserv/Parser.java
index 24746ed..eccb0c0 100644
--- a/modules/hidserv/src/org/torproject/metrics/hidserv/Parser.java
+++ b/modules/hidserv/src/org/torproject/metrics/hidserv/Parser.java
@@ -96,8 +96,7 @@ public class Parser {
   public void readParseHistory() {
     if (this.parseHistoryFile.exists()
         && this.parseHistoryFile.isFile()) {
-      SortedMap<String, Long> excludedFiles =
-          new TreeMap<String, Long>();
+      SortedMap<String, Long> excludedFiles = new TreeMap<>();
       try {
         BufferedReader br = new BufferedReader(new FileReader(
             this.parseHistoryFile));
@@ -133,8 +132,7 @@ public class Parser {
 
     /* Obtain the list of descriptor files that were either parsed now or
      * that were skipped in this execution from the descriptor reader. */
-    SortedMap<String, Long> excludedAndParsedFiles =
-        new TreeMap<String, Long>();
+    SortedMap<String, Long> excludedAndParsedFiles = new TreeMap<>();
     excludedAndParsedFiles.putAll(
         this.descriptorReader.getExcludedFiles());
     excludedAndParsedFiles.putAll(this.descriptorReader.getParsedFiles());
@@ -164,8 +162,7 @@ public class Parser {
    * <p>To date, these objects are small, and keeping them all in memory
    * is easy.  But if this ever changes, e.g., when more and more
    * statistics are added, this may not scale.</p> */
-  private Set<ReportedHidServStats> reportedHidServStats =
-      new HashSet<ReportedHidServStats>();
+  private Set<ReportedHidServStats> reportedHidServStats = new HashSet<>();
 
   /** Instructs the descriptor reader to parse descriptor files, and
    * handles the resulting parsed descriptors if they are either
@@ -297,14 +294,12 @@ public class Parser {
      * directories, in reverse order, so that we can later determine the
      * fingerprint distance between a directory and the directory
      * preceding it by three positions in the descriptor ring. */
-    SortedSet<String> hsDirs = new TreeSet<String>(
-        Collections.reverseOrder());
+    SortedSet<String> hsDirs = new TreeSet<>(Collections.reverseOrder());
 
     /* Prepare for computing the weights of all relays with the Fast flag
      * for being selected in the middle position. */
     double totalWeightsRendezvousPoint = 0.0;
-    SortedMap<String, Double> weightsRendezvousPoint =
-        new TreeMap<String, Double>();
+    SortedMap<String, Double> weightsRendezvousPoint = new TreeMap<>();
 
     /* Go through all status entries contained in the consensus. */
     for (Map.Entry<String, NetworkStatusEntry> e
@@ -343,8 +338,7 @@ public class Parser {
     /* Store all computed network fractions based on this consensus in a
      * set, which will then be written to disk in a single store
      * operation. */
-    Set<ComputedNetworkFractions> computedNetworkFractions =
-        new HashSet<ComputedNetworkFractions>();
+    Set<ComputedNetworkFractions> computedNetworkFractions = new HashSet<>();
 
     /* Remove all previously added directory fingerprints and re-add them
      * twice, once with a leading "0" and once with a leading "1".  The
@@ -352,7 +346,7 @@ public class Parser {
      * the previous one, even if that would mean traversing the ring
      * start.  For example, the fingerprint preceding "1""00..0000" with
      * the first "1" being added here could be "0""FF..FFFF". */
-    SortedSet<String> hsDirsCopy = new TreeSet<String>(hsDirs);
+    SortedSet<String> hsDirsCopy = new TreeSet<>(hsDirs);
     hsDirs.clear();
     for (String fingerprint : hsDirsCopy) {
       hsDirs.add("0" + fingerprint);
diff --git a/modules/hidserv/src/org/torproject/metrics/hidserv/Simulate.java b/modules/hidserv/src/org/torproject/metrics/hidserv/Simulate.java
index ab6389d..207b4aa 100644
--- a/modules/hidserv/src/org/torproject/metrics/hidserv/Simulate.java
+++ b/modules/hidserv/src/org/torproject/metrics/hidserv/Simulate.java
@@ -130,14 +130,13 @@ public class Simulate {
     double[] fractions = new double[] { 0.01, 0.02, 0.03, 0.04, 0.05, 0.1,
         0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.99 };
     for (double fraction : fractions) {
-      SortedSet<Integer> nonReportingRelays = new TreeSet<Integer>();
+      SortedSet<Integer> nonReportingRelays = new TreeSet<>();
       for (int j = 0; j < numberRendPoints; j++) {
         nonReportingRelays.add(j);
       }
-      List<Integer> shuffledRelays = new ArrayList<Integer>(
-          nonReportingRelays);
+      List<Integer> shuffledRelays = new ArrayList<>(nonReportingRelays);
       Collections.shuffle(shuffledRelays);
-      SortedSet<Integer> reportingRelays = new TreeSet<Integer>();
+      SortedSet<Integer> reportingRelays = new TreeSet<>();
       for (int j = 0; j < (int) ((double) numberRendPoints * fraction);
           j++) {
         reportingRelays.add(shuffledRelays.get(j));
@@ -146,7 +145,7 @@ public class Simulate {
       List<double[]> singleRelayExtrapolations;
       double totalReportingProbability;
       do {
-        singleRelayExtrapolations = new ArrayList<double[]>();
+        singleRelayExtrapolations = new ArrayList<>();
         totalReportingProbability = 0.0;
         for (int reportingRelay : reportingRelays) {
           double probability = probRendPoint[reportingRelay];
@@ -160,12 +159,12 @@ public class Simulate {
           totalReportingProbability += probability;
         }
         if (totalReportingProbability < fraction - 0.001) {
-          int addRelay = new ArrayList<Integer>(nonReportingRelays).get(
+          int addRelay = new ArrayList<>(nonReportingRelays).get(
               rnd.nextInt(nonReportingRelays.size()));
           nonReportingRelays.remove(addRelay);
           reportingRelays.add(addRelay);
         } else if (totalReportingProbability > fraction + 0.001) {
-          int removeRelay = new ArrayList<Integer>(reportingRelays).get(
+          int removeRelay = new ArrayList<>(reportingRelays).get(
               rnd.nextInt(reportingRelays.size()));
           reportingRelays.remove(removeRelay);
           nonReportingRelays.add(removeRelay);
@@ -208,20 +207,19 @@ public class Simulate {
 
     /* Generate 3000 HSDirs with "fingerprints" between 0.0 and 1.0. */
     final int numberHsDirs = 3000;
-    SortedSet<Double> hsDirFingerprints = new TreeSet<Double>();
+    SortedSet<Double> hsDirFingerprints = new TreeSet<>();
     for (int i = 0; i < numberHsDirs; i++) {
       hsDirFingerprints.add(rnd.nextDouble());
     }
 
     /* Compute fractions of observed descriptor space. */
     SortedSet<Double> ring =
-        new TreeSet<Double>(Collections.reverseOrder());
+        new TreeSet<>(Collections.reverseOrder());
     for (double fingerprint : hsDirFingerprints) {
       ring.add(fingerprint);
       ring.add(fingerprint - 1.0);
     }
-    SortedMap<Double, Double> hsDirFractions =
-        new TreeMap<Double, Double>();
+    SortedMap<Double, Double> hsDirFractions = new TreeMap<>();
     for (double fingerprint : hsDirFingerprints) {
       double start = fingerprint;
       int positionsToGo = 3;
@@ -238,8 +236,7 @@ public class Simulate {
     final int numberOnions = 40000;
     final int replicas = 4;
     final int storeOnDirs = 3;
-    SortedMap<Double, SortedSet<Integer>> storedDescs =
-        new TreeMap<Double, SortedSet<Integer>>();
+    SortedMap<Double, SortedSet<Integer>> storedDescs = new TreeMap<>();
     for (double fingerprint : hsDirFingerprints) {
       storedDescs.put(fingerprint, new TreeSet<Integer>());
     }
@@ -268,9 +265,8 @@ public class Simulate {
      * to remove noise again. */
     final long binSize = 8L;
     final double b = 8.0 / 0.3;
-    SortedMap<Double, Long> reportedOnions = new TreeMap<Double, Long>();
-    SortedMap<Double, Long> removedNoiseOnions =
-        new TreeMap<Double, Long>();
+    SortedMap<Double, Long> reportedOnions = new TreeMap<>();
+    SortedMap<Double, Long> removedNoiseOnions = new TreeMap<>();
     for (Map.Entry<Double, SortedSet<Integer>> e
         : storedDescs.entrySet()) {
       double fingerprint = e.getKey();
@@ -295,11 +291,11 @@ public class Simulate {
         0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.99 };
     for (double fraction : fractions) {
       SortedSet<Double> nonReportingRelays =
-          new TreeSet<Double>(hsDirFractions.keySet());
-      List<Double> shuffledRelays = new ArrayList<Double>(
+          new TreeSet<>(hsDirFractions.keySet());
+      List<Double> shuffledRelays = new ArrayList<>(
           nonReportingRelays);
       Collections.shuffle(shuffledRelays);
-      SortedSet<Double> reportingRelays = new TreeSet<Double>();
+      SortedSet<Double> reportingRelays = new TreeSet<>();
       for (int j = 0; j < (int) ((double) hsDirFractions.size()
           * fraction); j++) {
         reportingRelays.add(shuffledRelays.get(j));
@@ -308,7 +304,7 @@ public class Simulate {
       List<double[]> singleRelayExtrapolations;
       double totalReportingProbability;
       do {
-        singleRelayExtrapolations = new ArrayList<double[]>();
+        singleRelayExtrapolations = new ArrayList<>();
         totalReportingProbability = 0.0;
         for (double reportingRelay : reportingRelays) {
           double probability = hsDirFractions.get(reportingRelay) / 3.0;
@@ -322,13 +318,13 @@ public class Simulate {
         }
         if (totalReportingProbability < fraction - 0.001) {
           double addRelay =
-              new ArrayList<Double>(nonReportingRelays).get(
+              new ArrayList<>(nonReportingRelays).get(
               rnd.nextInt(nonReportingRelays.size()));
           nonReportingRelays.remove(addRelay);
           reportingRelays.add(addRelay);
         } else if (totalReportingProbability > fraction + 0.001) {
           double removeRelay =
-              new ArrayList<Double>(reportingRelays).get(
+              new ArrayList<>(reportingRelays).get(
               rnd.nextInt(reportingRelays.size()));
           reportingRelays.remove(removeRelay);
           nonReportingRelays.add(removeRelay);
diff --git a/modules/legacy/src/org/torproject/ernie/cron/Configuration.java b/modules/legacy/src/org/torproject/ernie/cron/Configuration.java
index d0e0d20..e0d753f 100644
--- a/modules/legacy/src/org/torproject/ernie/cron/Configuration.java
+++ b/modules/legacy/src/org/torproject/ernie/cron/Configuration.java
@@ -23,8 +23,7 @@ public class Configuration {
 
   private boolean importDirectoryArchives = false;
 
-  private List<String> directoryArchivesDirectories =
-      new ArrayList<String>();
+  private List<String> directoryArchivesDirectories = new ArrayList<>();
 
   private boolean keepDirectoryArchiveImportHistory = false;
 
diff --git a/modules/legacy/src/org/torproject/ernie/cron/RelayDescriptorDatabaseImporter.java b/modules/legacy/src/org/torproject/ernie/cron/RelayDescriptorDatabaseImporter.java
index aa1749e..97a330e 100644
--- a/modules/legacy/src/org/torproject/ernie/cron/RelayDescriptorDatabaseImporter.java
+++ b/modules/legacy/src/org/torproject/ernie/cron/RelayDescriptorDatabaseImporter.java
@@ -176,7 +176,7 @@ public final class RelayDescriptorDatabaseImporter {
    * Set of fingerprints that we imported for the valid-after time in
    * <code>lastCheckedStatusEntries</code>.
    */
-  private Set<String> insertedStatusEntries = new HashSet<String>();
+  private Set<String> insertedStatusEntries = new HashSet<>();
 
   private boolean importIntoDatabase;
 
@@ -242,7 +242,7 @@ public final class RelayDescriptorDatabaseImporter {
             + "(validafter) VALUES (?)");
         this.psU = conn.prepareStatement("INSERT INTO scheduled_updates "
             + "(date) VALUES (?)");
-        this.scheduledUpdates = new HashSet<Long>();
+        this.scheduledUpdates = new HashSet<>();
         this.importIntoDatabase = true;
       } catch (SQLException e) {
         this.logger.log(Level.WARNING, "Could not connect to database or "
@@ -576,7 +576,7 @@ public final class RelayDescriptorDatabaseImporter {
 
     /* Split history lines by date and rewrite them so that the date
      * comes first. */
-    SortedSet<String> historyLinesByDate = new TreeSet<String>();
+    SortedSet<String> historyLinesByDate = new TreeSet<>();
     for (String bandwidthHistoryString : bandwidthHistoryStrings) {
       String[] parts = bandwidthHistoryString.split(" ");
       if (parts.length != 6) {
@@ -641,7 +641,7 @@ public final class RelayDescriptorDatabaseImporter {
       }
       long currentIntervalEnd = intervalEnd;
       StringBuilder sb = new StringBuilder();
-      SortedSet<String> newHistoryLines = new TreeSet<String>();
+      SortedSet<String> newHistoryLines = new TreeSet<>();
       try {
         for (int i = values.length - 1; i >= -1; i--) {
           if (i == -1 || currentIntervalEnd < dateStart) {
@@ -898,7 +898,7 @@ public final class RelayDescriptorDatabaseImporter {
   }
 
   private void addExtraInfoDescriptor(ExtraInfoDescriptor descriptor) {
-    List<String> bandwidthHistoryLines = new ArrayList<String>();
+    List<String> bandwidthHistoryLines = new ArrayList<>();
     if (descriptor.getWriteHistory() != null) {
       bandwidthHistoryLines.add(descriptor.getWriteHistory().getLine());
     }
diff --git a/modules/legacy/src/org/torproject/ernie/cron/network/ConsensusStatsFileHandler.java b/modules/legacy/src/org/torproject/ernie/cron/network/ConsensusStatsFileHandler.java
index 9c0c01e..aa9469e 100644
--- a/modules/legacy/src/org/torproject/ernie/cron/network/ConsensusStatsFileHandler.java
+++ b/modules/legacy/src/org/torproject/ernie/cron/network/ConsensusStatsFileHandler.java
@@ -102,8 +102,8 @@ public class ConsensusStatsFileHandler {
 
     /* Initialize local data structures to hold intermediate and final
      * results. */
-    this.bridgesPerDay = new TreeMap<String, String>();
-    this.bridgesRaw = new TreeMap<String, String>();
+    this.bridgesPerDay = new TreeMap<>();
+    this.bridgesRaw = new TreeMap<>();
 
     /* Initialize file names for intermediate and final results files. */
     this.bridgeConsensusStatsRawFile = new File(
@@ -251,8 +251,7 @@ public class ConsensusStatsFileHandler {
 
     /* Go through raw observations and put everything into nested maps by day
      * and bridge authority. */
-    Map<String, Map<String, int[]>> bridgesPerDayAndAuthority =
-        new HashMap<String, Map<String, int[]>>();
+    Map<String, Map<String, int[]>> bridgesPerDayAndAuthority = new HashMap<>();
     for (String bridgesRawLine : this.bridgesRaw.values()) {
       String date = bridgesRawLine.substring(0, 10);
       if (!bridgesPerDayAndAuthority.containsKey(date)) {
@@ -322,8 +321,8 @@ public class ConsensusStatsFileHandler {
     /* Add average number of bridges per day to the database. */
     if (connectionUrl != null) {
       try {
-        Map<String, String> insertRows = new HashMap<String, String>();
-        Map<String, String> updateRows = new HashMap<String, String>();
+        Map<String, String> insertRows = new HashMap<>();
+        Map<String, String> updateRows = new HashMap<>();
         insertRows.putAll(this.bridgesPerDay);
         Connection conn = DriverManager.getConnection(connectionUrl);
         conn.setAutoCommit(false);
diff --git a/modules/legacy/src/org/torproject/ernie/cron/performance/TorperfProcessor.java b/modules/legacy/src/org/torproject/ernie/cron/performance/TorperfProcessor.java
index b3bb2e3..2883299 100644
--- a/modules/legacy/src/org/torproject/ernie/cron/performance/TorperfProcessor.java
+++ b/modules/legacy/src/org/torproject/ernie/cron/performance/TorperfProcessor.java
@@ -40,8 +40,8 @@ public class TorperfProcessor {
     Logger logger = Logger.getLogger(TorperfProcessor.class.getName());
     File rawFile = new File(statsDirectory, "torperf-raw");
     File statsFile = new File(statsDirectory, "torperf.csv");
-    SortedMap<String, String> rawObs = new TreeMap<String, String>();
-    SortedMap<String, String> stats = new TreeMap<String, String>();
+    SortedMap<String, String> rawObs = new TreeMap<>();
+    SortedMap<String, String> stats = new TreeMap<>();
     int addedRawObs = 0;
     SimpleDateFormat formatter =
         new SimpleDateFormat("yyyy-MM-dd,HH:mm:ss");
@@ -144,12 +144,10 @@ public class TorperfProcessor {
         String tempSourceDate = null;
         Iterator<Map.Entry<String, String>> it =
             rawObs.entrySet().iterator();
-        List<Long> dlTimes = new ArrayList<Long>();
+        List<Long> dlTimes = new ArrayList<>();
         boolean haveWrittenFinalLine = false;
-        SortedMap<String, List<Long>> dlTimesAllSources =
-            new TreeMap<String, List<Long>>();
-        SortedMap<String, long[]> statusesAllSources =
-            new TreeMap<String, long[]>();
+        SortedMap<String, List<Long>> dlTimesAllSources = new TreeMap<>();
+        SortedMap<String, long[]> statusesAllSources = new TreeMap<>();
         long failures = 0;
         long timeouts = 0;
         long requests = 0;
@@ -196,7 +194,7 @@ public class TorperfProcessor {
                 statusesAllSources.put(allDateSizeSource, status);
               }
             }
-            dlTimes = new ArrayList<Long>();
+            dlTimes = new ArrayList<>();
             failures = timeouts = requests = 0;
             if (next == null) {
               haveWrittenFinalLine = true;
diff --git a/modules/webstats/src/main/java/org/torproject/metrics/webstats/Main.java b/modules/webstats/src/main/java/org/torproject/metrics/webstats/Main.java
index 4c02a0f..7ba08d7 100644
--- a/modules/webstats/src/main/java/org/torproject/metrics/webstats/Main.java
+++ b/modules/webstats/src/main/java/org/torproject/metrics/webstats/Main.java
@@ -391,7 +391,7 @@ public class Main {
   static void writeStatistics(Path webstatsPath,
       SortedSet<String> statistics) throws IOException {
     webstatsPath.toFile().getParentFile().mkdirs();
-    List<String> lines = new ArrayList<String>();
+    List<String> lines = new ArrayList<>();
     lines.add(ALL_COLUMNS);
     lines.addAll(statistics);
     log.info("Writing {} lines to {}.", lines.size(),
diff --git a/website/build.xml b/website/build.xml
index c3aca68..6204afe 100644
--- a/website/build.xml
+++ b/website/build.xml
@@ -7,8 +7,8 @@
     <mkdir dir="classes"/>
     <javac destdir="classes"
            srcdir="src"
-           source="1.5"
-           target="1.5"
+           source="1.7"
+           target="1.7"
            debug="true"
            deprecation="true"
            optimize="false"
diff --git a/website/src/org/torproject/metrics/web/AnyServlet.java b/website/src/org/torproject/metrics/web/AnyServlet.java
index 696a3be..3f2c073 100644
--- a/website/src/org/torproject/metrics/web/AnyServlet.java
+++ b/website/src/org/torproject/metrics/web/AnyServlet.java
@@ -14,7 +14,7 @@ public abstract class AnyServlet extends HttpServlet {
 
   @Override
   public void init() throws ServletException {
-    List<String[]> categories = new ArrayList<String[]>();
+    List<String[]> categories = new ArrayList<>();
     for (Category category :
         ContentProvider.getInstance().getCategoriesList()) {
       categories.add(new String[] {
diff --git a/website/src/org/torproject/metrics/web/ContentProvider.java b/website/src/org/torproject/metrics/web/ContentProvider.java
index 7dd9c46..f31c3d0 100644
--- a/website/src/org/torproject/metrics/web/ContentProvider.java
+++ b/website/src/org/torproject/metrics/web/ContentProvider.java
@@ -39,15 +39,15 @@ public class ContentProvider {
   }
 
   public List<Metric> getMetricsList() {
-    return new ArrayList<Metric>(this.metricsList);
+    return new ArrayList<>(this.metricsList);
   }
 
   public List<Category> getCategoriesList() {
-    return new ArrayList<Category>(this.categoriesList);
+    return new ArrayList<>(this.categoriesList);
   }
 
   public List<News> getNewsList() {
-    return new ArrayList<News>(this.newsList);
+    return new ArrayList<>(this.newsList);
   }
 }
 
diff --git a/website/src/org/torproject/metrics/web/GraphServlet.java b/website/src/org/torproject/metrics/web/GraphServlet.java
index cc5edf1..0503195 100644
--- a/website/src/org/torproject/metrics/web/GraphServlet.java
+++ b/website/src/org/torproject/metrics/web/GraphServlet.java
@@ -25,8 +25,7 @@ import javax.servlet.http.HttpServletResponse;
 @SuppressWarnings("serial")
 public class GraphServlet extends MetricServlet {
 
-  private Map<String, String[][]> defaultParameters =
-      new HashMap<String, String[][]>();
+  private Map<String, String[][]> defaultParameters = new HashMap<>();
 
   @Override
   public void init() throws ServletException {
@@ -141,7 +140,7 @@ public class GraphServlet extends MetricServlet {
       Category category = this.categoriesById.get(requestedId);
       request.setAttribute("categoryHeader", category.getHeader());
       request.setAttribute("categoryDescription", category.getDescription());
-      List<String[]> categoryTabs = new ArrayList<String[]>();
+      List<String[]> categoryTabs = new ArrayList<>();
       for (String metricId : category.getMetrics()) {
         categoryTabs.add(new String[] { this.titles.get(metricId), metricId });
       }
@@ -190,7 +189,7 @@ public class GraphServlet extends MetricServlet {
           Set<String> checked = null;
           if (checkedParameters != null
               && checkedParameters.containsKey(parameter)) {
-            checked = new HashSet<String>(Arrays.asList(
+            checked = new HashSet<>(Arrays.asList(
                 checkedParameters.get(parameter)));
           }
           String checkedOrSelected = parameter.equals("country")
diff --git a/website/src/org/torproject/metrics/web/LinkServlet.java b/website/src/org/torproject/metrics/web/LinkServlet.java
index 84b5da9..2319660 100644
--- a/website/src/org/torproject/metrics/web/LinkServlet.java
+++ b/website/src/org/torproject/metrics/web/LinkServlet.java
@@ -42,7 +42,7 @@ public class LinkServlet extends MetricServlet {
       Category category = this.categoriesById.get(requestedId);
       request.setAttribute("categoryHeader", category.getHeader());
       request.setAttribute("categoryDescription", category.getDescription());
-      List<String[]> categoryTabs = new ArrayList<String[]>();
+      List<String[]> categoryTabs = new ArrayList<>();
       for (String metricId : category.getMetrics()) {
         categoryTabs.add(new String[] { this.titles.get(metricId), metricId });
       }
diff --git a/website/src/org/torproject/metrics/web/MetricServlet.java b/website/src/org/torproject/metrics/web/MetricServlet.java
index d2f2a7f..02dcd53 100644
--- a/website/src/org/torproject/metrics/web/MetricServlet.java
+++ b/website/src/org/torproject/metrics/web/MetricServlet.java
@@ -18,34 +18,27 @@ public abstract class MetricServlet extends AnyServlet {
 
   protected List<Metric> metrics;
 
-  protected Map<String, Set<String>> idsByType =
-      new HashMap<String, Set<String>>();
+  protected Map<String, Set<String>> idsByType = new HashMap<>();
 
-  protected Map<String, String> descriptions =
-      new HashMap<String, String>();
+  protected Map<String, String> descriptions = new HashMap<>();
 
-  protected Map<String, String> titles = new HashMap<String, String>();
+  protected Map<String, String> titles = new HashMap<>();
 
-  protected Map<String, List<String>> parameters =
-      new HashMap<String, List<String>>();
+  protected Map<String, List<String>> parameters = new HashMap<>();
 
-  protected Map<String, String[]> tableHeaders =
-      new HashMap<String, String[]>();
+  protected Map<String, String[]> tableHeaders = new HashMap<>();
 
-  protected Map<String, String[]> tableCellFormats =
-      new HashMap<String, String[]>();
+  protected Map<String, String[]> tableCellFormats = new HashMap<>();
 
-  protected Map<String, String[]> data =
-      new HashMap<String, String[]>();
+  protected Map<String, String[]> data = new HashMap<>();
 
-  protected Map<String, Category> categoriesById =
-      new HashMap<String, Category>();
+  protected Map<String, Category> categoriesById = new HashMap<>();
 
   @Override
   public void init() throws ServletException {
     super.init();
     this.metrics = ContentProvider.getInstance().getMetricsList();
-    Map<String, String> allTypesAndTitles = new HashMap<String, String>();
+    Map<String, String> allTypesAndTitles = new HashMap<>();
     for (Metric metric : this.metrics) {
       String id = metric.getId();
       String title = metric.getTitle();
diff --git a/website/src/org/torproject/metrics/web/NewsServlet.java b/website/src/org/torproject/metrics/web/NewsServlet.java
index cb1b93b..3df80d0 100644
--- a/website/src/org/torproject/metrics/web/NewsServlet.java
+++ b/website/src/org/torproject/metrics/web/NewsServlet.java
@@ -33,7 +33,7 @@ public class NewsServlet extends AnyServlet {
   @Override
   public void init() throws ServletException {
     super.init();
-    List<News> sortedNews = new ArrayList<News>();
+    List<News> sortedNews = new ArrayList<>();
     for (News news : ContentProvider.getInstance().getNewsList()) {
       if (news.getStart() != null) {
         sortedNews.add(news);
@@ -45,7 +45,7 @@ public class NewsServlet extends AnyServlet {
       }
     });
     this.sortedNews = sortedNews;
-    SortedMap<String, String> countries = new TreeMap<String, String>();
+    SortedMap<String, String> countries = new TreeMap<>();
     for (String[] country : Countries.getInstance().getCountryList()) {
       countries.put(country[0], country[1]);
     }
@@ -57,7 +57,7 @@ public class NewsServlet extends AnyServlet {
       HttpServletResponse response) throws IOException, ServletException {
 
     /* Create categories based on current system time. */
-    Map<String, String[]> cutOffDates = new LinkedHashMap<String, String[]>();
+    Map<String, String[]> cutOffDates = new LinkedHashMap<>();
     Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"), Locale.US);
     cal.set(Calendar.DAY_OF_WEEK, 1);
     cutOffDates.put(String.format("%tF", cal),
@@ -81,8 +81,7 @@ public class NewsServlet extends AnyServlet {
         && yearStart.compareTo(this.sortedNews.get(0).getStart()) > 0);
 
     /* Sort news into categories. */
-    Map<String[], List<String[]>> newsByCategory =
-        new LinkedHashMap<String[], List<String[]>>();
+    Map<String[], List<String[]>> newsByCategory = new LinkedHashMap<>();
     for (String[] category : cutOffDates.values()) {
       newsByCategory.put(category, new ArrayList<String[]>());
     }
diff --git a/website/src/org/torproject/metrics/web/TableServlet.java b/website/src/org/torproject/metrics/web/TableServlet.java
index 4e20704..d8ffbb1 100644
--- a/website/src/org/torproject/metrics/web/TableServlet.java
+++ b/website/src/org/torproject/metrics/web/TableServlet.java
@@ -55,7 +55,7 @@ public class TableServlet extends MetricServlet {
       Category category = this.categoriesById.get(requestedId);
       request.setAttribute("categoryHeader", category.getHeader());
       request.setAttribute("categoryDescription", category.getDescription());
-      List<String[]> categoryTabs = new ArrayList<String[]>();
+      List<String[]> categoryTabs = new ArrayList<>();
       for (String metricId : category.getMetrics()) {
         categoryTabs.add(new String[] { this.titles.get(metricId), metricId });
       }
@@ -92,11 +92,10 @@ public class TableServlet extends MetricServlet {
     }
     List<Map<String, String>> tableData = objectGenerator
         .generateTable(requestedId, request.getParameterMap(), true);
-    List<List<String>> formattedTableData =
-        new ArrayList<List<String>>();
+    List<List<String>> formattedTableData = new ArrayList<>();
     String[] contents = this.tableCellFormats.get(requestedId);
     for (Map<String, String> row : tableData) {
-      List<String> formattedRow = new ArrayList<String>();
+      List<String> formattedRow = new ArrayList<>();
       StrSubstitutor sub = new StrSubstitutor(row);
       for (String con : contents) {
         formattedRow.add(sub.replace(con));
diff --git a/website/src/org/torproject/metrics/web/graphs/BubblesServlet.java b/website/src/org/torproject/metrics/web/graphs/BubblesServlet.java
index 8f5749a..0348924 100644
--- a/website/src/org/torproject/metrics/web/graphs/BubblesServlet.java
+++ b/website/src/org/torproject/metrics/web/graphs/BubblesServlet.java
@@ -40,7 +40,7 @@ public class BubblesServlet extends MetricServlet {
       Category category = this.categoriesById.get(requestedId);
       request.setAttribute("categoryHeader", category.getHeader());
       request.setAttribute("categoryDescription", category.getDescription());
-      List<String[]> categoryTabs = new ArrayList<String[]>();
+      List<String[]> categoryTabs = new ArrayList<>();
       for (String metricId : category.getMetrics()) {
         categoryTabs.add(new String[] { this.titles.get(metricId), metricId });
       }
diff --git a/website/src/org/torproject/metrics/web/graphs/Countries.java b/website/src/org/torproject/metrics/web/graphs/Countries.java
index 9355641..c10af45 100644
--- a/website/src/org/torproject/metrics/web/graphs/Countries.java
+++ b/website/src/org/torproject/metrics/web/graphs/Countries.java
@@ -19,7 +19,7 @@ public class Countries {
   private List<String[]> knownCountries;
 
   private Countries() {
-    this.knownCountries = new ArrayList<String[]>();
+    this.knownCountries = new ArrayList<>();
     this.knownCountries.add("af;Afghanistan".split(";"));
     this.knownCountries.add("ax;Aland Islands".split(";"));
     this.knownCountries.add("al;Albania".split(";"));
diff --git a/website/src/org/torproject/metrics/web/graphs/GraphParameterChecker.java b/website/src/org/torproject/metrics/web/graphs/GraphParameterChecker.java
index 580e914..0b39adb 100644
--- a/website/src/org/torproject/metrics/web/graphs/GraphParameterChecker.java
+++ b/website/src/org/torproject/metrics/web/graphs/GraphParameterChecker.java
@@ -49,13 +49,13 @@ public class GraphParameterChecker {
   public GraphParameterChecker() {
     this.dateFormat = new SimpleDateFormat("yyyy-MM-dd");
     this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
-    this.availableGraphs = new HashMap<String, String[]>();
+    this.availableGraphs = new HashMap<>();
     for (Metric metric : ContentProvider.getInstance().getMetricsList()) {
       if ("Graph".equals(metric.getType())) {
         this.availableGraphs.put(metric.getId(), metric.getParameters());
       }
     }
-    this.knownParameterValues = new HashMap<String, String>();
+    this.knownParameterValues = new HashMap<>();
     this.knownParameterValues.put("flag",
         "Running,Exit,Guard,Fast,Stable,HSDir");
     StringBuilder sb = new StringBuilder("all");
@@ -92,10 +92,9 @@ public class GraphParameterChecker {
 
     /* Find out which other parameters are supported by this graph type
      * and parse them if they are given. */
-    Set<String> supportedGraphParameters = new HashSet<String>(
+    Set<String> supportedGraphParameters = new HashSet<>(
         Arrays.asList(this.availableGraphs.get(graphType)));
-    Map<String, String[]> recognizedGraphParameters =
-        new HashMap<String, String[]>();
+    Map<String, String[]> recognizedGraphParameters = new HashMap<>();
 
     /* Parse start and end dates if supported by the graph type. If no end
      * date is provided, set it to today. If no start date is provided,
diff --git a/website/src/org/torproject/metrics/web/graphs/RObjectGenerator.java b/website/src/org/torproject/metrics/web/graphs/RObjectGenerator.java
index acdb146..aa6ab4f 100644
--- a/website/src/org/torproject/metrics/web/graphs/RObjectGenerator.java
+++ b/website/src/org/torproject/metrics/web/graphs/RObjectGenerator.java
@@ -57,8 +57,8 @@ public class RObjectGenerator implements ServletContextListener {
     this.cachedGraphsDirectory = servletContext.getInitParameter(
         "cachedGraphsDir");
 
-    this.availableGraphs = new LinkedHashMap<String, Metric>();
-    this.availableTables = new LinkedHashMap<String, Metric>();
+    this.availableGraphs = new LinkedHashMap<>();
+    this.availableTables = new LinkedHashMap<>();
     for (Metric metric : ContentProvider.getInstance().getMetricsList()) {
       String type = metric.getType();
       String id = metric.getId();
@@ -216,19 +216,18 @@ public class RObjectGenerator implements ServletContextListener {
     /* Write the table content to a map. */
     List<Map<String, String>> result = null;
     try {
-      result = new ArrayList<Map<String, String>>();
+      result = new ArrayList<>();
       BufferedReader br = new BufferedReader(new InputStreamReader(
           new ByteArrayInputStream(tableBytes)));
       String line = br.readLine();
       if (line != null) {
-        List<String> headers = new ArrayList<String>(Arrays.asList(
-            line.split(",")));
+        List<String> headers = new ArrayList<>(Arrays.asList(line.split(",")));
         while ((line = br.readLine()) != null) {
           String[] parts = line.split(",");
           if (headers.size() != parts.length) {
             return null;
           }
-          Map<String, String> row = new HashMap<String, String>();
+          Map<String, String> row = new HashMap<>();
           for (int i = 0; i < headers.size(); i++) {
             row.put(headers.get(i), parts[i]);
           }
@@ -273,7 +272,7 @@ public class RObjectGenerator implements ServletContextListener {
   }
 
   private Map<String, RObjectGeneratorWorker> objectGeneratorThreads =
-      new HashMap<String, RObjectGeneratorWorker>();
+      new HashMap<>();
 
   private class RObjectGeneratorWorker extends Thread {
 
diff --git a/website/src/org/torproject/metrics/web/graphs/TableParameterChecker.java b/website/src/org/torproject/metrics/web/graphs/TableParameterChecker.java
index fea04c8..eb13531 100644
--- a/website/src/org/torproject/metrics/web/graphs/TableParameterChecker.java
+++ b/website/src/org/torproject/metrics/web/graphs/TableParameterChecker.java
@@ -46,7 +46,7 @@ public class TableParameterChecker {
     this.dateFormat = new SimpleDateFormat("yyyy-MM-dd");
     this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
 
-    this.availableTables = new HashMap<String, String[]>();
+    this.availableTables = new HashMap<>();
     for (Metric metric : ContentProvider.getInstance().getMetricsList()) {
       if ("Table".equals(metric.getType())) {
         this.availableTables.put(metric.getId(), metric.getParameters());
@@ -70,10 +70,9 @@ public class TableParameterChecker {
 
     /* Find out which other parameters are supported by this table type
      * and parse them if they are given. */
-    Set<String> supportedTableParameters = new HashSet<String>(
+    Set<String> supportedTableParameters = new HashSet<>(
         Arrays.asList(this.availableTables.get(tableType)));
-    Map<String, String[]> recognizedTableParameters =
-        new HashMap<String, String[]>();
+    Map<String, String[]> recognizedTableParameters = new HashMap<>();
 
     /* Parse start and end dates if supported by the table type. If no end
      * date is provided, set it to today. If no start date is provided,
diff --git a/website/src/org/torproject/metrics/web/research/ResearchStatsServlet.java b/website/src/org/torproject/metrics/web/research/ResearchStatsServlet.java
index 42be8f6..eaea36c 100644
--- a/website/src/org/torproject/metrics/web/research/ResearchStatsServlet.java
+++ b/website/src/org/torproject/metrics/web/research/ResearchStatsServlet.java
@@ -29,7 +29,7 @@ public class ResearchStatsServlet extends HttpServlet {
   public void init(ServletConfig config) throws ServletException {
     super.init(config);
     this.statsDir = new File(config.getInitParameter("statsDir"));
-    this.availableStatisticsFiles = new TreeSet<String>();
+    this.availableStatisticsFiles = new TreeSet<>();
     this.availableStatisticsFiles.add("servers");
     this.availableStatisticsFiles.add("bandwidth");
     this.availableStatisticsFiles.add("clients");





More information about the tor-commits mailing list