RFR 8143964: JShell API: convert query responses to Stream instead of List/Collection
Robert Field
robert.field at oracle.com
Tue Aug 9 21:49:05 UTC 2016
Thumbs up?
-Robert
On 08/09/16 13:34, Paul Sandoz wrote:
>> On 9 Aug 2016, at 13:24, Robert Field <robert.field at oracle.com> wrote:
>>
>>
>> On 08/09/16 13:04, Paul Sandoz wrote:
>>> Hi,
>>>
>>> Looks ok, just some minor stuff.
>> Thanks, Paul, for the review. See below.
>>>
>>> JShellTool
>>> —
>>>
>>> 1027 Stream<PersistentSnippet> dropableSnippets() {
>>> 1028 return state.snippets()
>>> 1029 .filter(sn -> state.status(sn).isActive() && sn instanceof PersistentSnippet)
>>> 1030 .map(sn -> (PersistentSnippet) sn);
>>> 1031 }
>>>
>>>
>>> Not sure if you can do PersistentSnippet.class::cast, if so up to you.
>> Is that preferred?
>>
> It’s subjective, I might prefer it :-) it was just a suggestion if you prefer it.
>
>
>>>
>>> 1895 Stream<Snippet> sns = at.hasOption("-all")
>>> 1896 ? state.snippets()
>>> 1897 : state.snippets().filter(this::mainActive);
>>> 1898 Iterator<Snippet> it = sns.iterator();
>>> 1899 while (it.hasNext()) {
>>> 1900 Snippet sn = it.next();
>>> 1901 writer.write(sn.source());
>>> 1902 writer.write("\n");
>>> 1903 }
>>>
>>> You can use forEach instead of an iterator.
>> Actually, the "write" can thrown IOException.
>>
> Ah, ok, i missed that.
>
> Paul.
More information about the kulla-dev
mailing list