Skip to content
Snippets Groups Projects
  • Dongjoon Hyun's avatar
    c3689bc2
    [SPARK-13702][CORE][SQL][MLLIB] Use diamond operator for generic instance creation in Java code. · c3689bc2
    Dongjoon Hyun authored
    ## What changes were proposed in this pull request?
    
    In order to make `docs/examples` (and other related code) more simple/readable/user-friendly, this PR replaces existing codes like the followings by using `diamond` operator.
    
    ```
    -    final ArrayList<Product2<Object, Object>> dataToWrite =
    -      new ArrayList<Product2<Object, Object>>();
    +    final ArrayList<Product2<Object, Object>> dataToWrite = new ArrayList<>();
    ```
    
    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.
    
    ## How was this patch tested?
    
    Manual.
    Pass the existing tests.
    
    Author: Dongjoon Hyun <dongjoon@apache.org>
    
    Closes #11541 from dongjoon-hyun/SPARK-13702.
    c3689bc2
    History
    [SPARK-13702][CORE][SQL][MLLIB] Use diamond operator for generic instance creation in Java code.
    Dongjoon Hyun authored
    ## What changes were proposed in this pull request?
    
    In order to make `docs/examples` (and other related code) more simple/readable/user-friendly, this PR replaces existing codes like the followings by using `diamond` operator.
    
    ```
    -    final ArrayList<Product2<Object, Object>> dataToWrite =
    -      new ArrayList<Product2<Object, Object>>();
    +    final ArrayList<Product2<Object, Object>> dataToWrite = new ArrayList<>();
    ```
    
    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.
    
    ## How was this patch tested?
    
    Manual.
    Pass the existing tests.
    
    Author: Dongjoon Hyun <dongjoon@apache.org>
    
    Closes #11541 from dongjoon-hyun/SPARK-13702.