You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Dongjoon Hyun (JIRA)" <ji...@apache.org> on 2016/03/06 00:42:40 UTC

[jira] [Created] (SPARK-13702) Use diamond operator for generic instance creation in Java code

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-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org