You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2015/11/24 19:17:11 UTC

[jira] [Commented] (FLINK-3075) Rename Either creation methods to avoid name clash with projection methods

    [ https://issues.apache.org/jira/browse/FLINK-3075?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15025022#comment-15025022 ] 

ASF GitHub Bot commented on FLINK-3075:
---------------------------------------

GitHub user gyfora opened a pull request:

    https://github.com/apache/flink/pull/1402

    [FLINK-3075] Change Either creation method names and expose Right/Left classes

    This PR changes the way users can create the Either objects to make it more java 8 friendly.
    
    The Either.left(left) and Either.right(right) have been renamed to createLeft and createRight respectively and now the Right and Left classes are directly exposed as well. 
    
    This is more inline with how it is in scala and avoids method name clashes when trying to reference the Either methods from java lambdas allowing to do something like:
    
    `((List<Either<String, Integer>>) l).stream().filter(Either::isLeft).map(Either::left);`

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/gyfora/flink either

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/flink/pull/1402.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1402
    
----
commit 40bc28bc07f46defe49fea7f007f2a765f0c022d
Author: Gyula Fora <gy...@apache.org>
Date:   2015-11-24T18:00:36Z

    [FLINK-3075] Change Either creation method names and expose Right/Left classes

----


> Rename Either creation methods to avoid name clash with projection methods
> --------------------------------------------------------------------------
>
>                 Key: FLINK-3075
>                 URL: https://issues.apache.org/jira/browse/FLINK-3075
>             Project: Flink
>          Issue Type: Improvement
>          Components: Java API
>            Reporter: Gyula Fora
>            Assignee: Gyula Fora
>            Priority: Minor
>
> Currently the method signatures for creating Either values `Either.left(left)` and the projection methods `either.left()` only differ in the parameters. 
> This makes it awkward to use with lambdas such as: 'eitherStream.filter(Either:isLeft).map(Either::left)'
> The above code is currently impossible.
> I suggest to change the creation methods to `Either.createLeft(left)` and `Either.createRight(right)` and also to directly expose the Left, Right classes.



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