Dongjoon Hyun created SPARK-13702:
-------------------------------------

             Summary: Use diamond operator for generic instance creation in 
Java code
                 Key: SPARK-13702
                 URL: https://issues.apache.org/jira/browse/SPARK-13702
             Project: Spark
          Issue Type: Improvement
            Reporter: Dongjoon Hyun
            Priority: Trivial


Java 7 or higher supports `diamond` operator which replaces the type arguments 
required to invoke the constructor of a generic class with an empty set of type 
parameters (<>). Currently, Spark Java code use mixed usage of this. This issue 
replaces existing codes to use `diamond` operator and add Checkstyle rule.

{code}
-List<JavaPairDStream<String, String>> kafkaStreams = new 
ArrayList<JavaPairDStream<String, String>>(numStreams);
+List<JavaPairDStream<String, String>> kafkaStreams = new 
ArrayList<>(numStreams);
{code}

{code}
-    Set<Tuple2<Integer, Integer>> edges = new HashSet<Tuple2<Integer, 
Integer>>(numEdges);
+    Set<Tuple2<Integer, Integer>> edges = new HashSet<>(numEdges);
{code}

*Reference*
https://docs.oracle.com/javase/8/docs/technotes/guides/language/type-inference-generic-instance-creation.html



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to