RFR: 1256: Use stream api to simplify the csr issue lookup [v3]
Magnus Ihse Bursie
ihse at openjdk.java.net
Wed Dec 1 13:40:55 UTC 2021
On Wed, 1 Dec 2021 08:00:15 GMT, Guoxiong Li <gli at openjdk.org> wrote:
>> Hi all,
>>
>> This patch adds the common methods `Issue#linksWithRelationships`, `Issue#csrLink` and `Issue#csrIssue` and refactors the code to reduce the loop nested statements by using these common methods.
>>
>> All the existing tests passed.
>>
>> Best Regards,
>> -- Guoxiong
>
> Guoxiong Li has updated the pull request incrementally with one additional commit since the last revision:
>
> Improve the encapsulation and use the methods of the 'Optional' instead of direct null check
bots/csr/src/main/java/org/openjdk/skara/bots/csr/CSRBot.java line 85:
> 83: var csrOptional = jbsIssue.get().links().stream()
> 84: .filter(link -> link.relationship().isPresent() && "csr for".equals(link.relationship().get()))
> 85: .findAny().flatMap(Link::issue);
I realize you'd be breaking abstractions by using csrLink() from CSRCommand, but maybe you can create a duplicated csrLink method here? I think it would help with readability, at least. And if we ever refactor this more, it would be a clear candidate to move to a class that is accessible from both here and CSRCommand.
-------------
PR: https://git.openjdk.java.net/skara/pull/1248
More information about the skara-dev
mailing list