Re: RFR: JDK-8200436 - String::isBlank

2018-05-17 Thread Jim Laskey
“isBlank" was primarily chosen because isBlank has been the name used in Apache 
StringUtils for the last fifteen years. The fact that Excel and Kotlin use 
isBlank as well might have influenced the choice. Not many other languages have 
the isBlank concept, usually requiring several method calls to gather the same 
effect. Secondarily, isBlank was chosen because of brevity, in the same vein as 
isEmpty.

The primary use case I see for the predicate is to filter out “blank” lines in 
streams of strings; eliminate non-informational data. As a predicate, isBlank 
seems very apropos. The name reflects its purpose and not focused on how it is 
implemented.

Cheers,

— Jim


> On May 16, 2018, at 1:43 AM, Jeremy Manson <jeremyman...@google.com> wrote:
> 
> Blank can even mean U+2422, if it comes to that.
> 
> Jeremy
> 
> On Tue, May 15, 2018 at 12:58 PM Louis Wasserman <lowas...@google.com>
> wrote:
> 
>> Does this method offer significant benefits over the more general approach
>> of String.codePoints().allMatch(Character::isWhitespace)?
>> 
>> " there is a notion of all characters in > > isBlank that you do not have
>> with isWhitespace."
>> I'm not sure I follow.  I do tend to interpret "is this string whitespace?"
>> as implying that it consists only of whitespace, whereas "blank" could mean
>> "" or maybe even "___" but not obviously "   ".
>> 
>> On Tue, May 15, 2018 at 11:19 AM Jonathan Bluett-Duncan <
>> jbluettdun...@gmail.com> wrote:
>> 
>>> How about String.isWhitespaceOrEmpty? I think that accurately describes
>> the
>>> method.
>>> 
>>> Cheers,
>>> Jonathan
>>> 
>>> On 15 May 2018 at 19:15, Jeremy Manson <jeremyman...@google.com> wrote:
>>> 
>>>> Seems to me that consistency matters here: for Character to call it
>>>> whitespace and for String to call it blank is a little weird.
>>>> 
>>>> Is there a well-understood definition of "blank string", or did this
>> just
>>>> seem like a good name choice?
>>>> 
>>>> Jeremy
>>>> 
>>>> On Mon, May 14, 2018 at 11:14 PM Remi Forax <fo...@univ-mlv.fr> wrote:
>>>> 
>>>>> Hi Louis,
>>>>> I prefer isBlank to isWhitespace, there is a notion of all characters
>>> in
>>>>> isBlank that you do not have with isWhitespace.
>>>>> 
>>>>> Rémi
>>>>> 
>>>>> - Mail original -
>>>>>> De: "Louis Wasserman" <lowas...@google.com>
>>>>>> À: "Xueming Shen" <xueming.s...@oracle.com>
>>>>>> Cc: "core-libs-dev" <core-libs-dev@openjdk.java.net>
>>>>>> Envoyé: Lundi 14 Mai 2018 22:15:50
>>>>>> Objet: Re: RFR: JDK-8200436 - String::isBlank
>>>>> 
>>>>>> It's not clear to me that "isBlank" is a good name for this method.
>>>>>> "isWhitespace" might be more appropriate, perhaps.
>>>>>> 
>>>>>> On Mon, May 14, 2018 at 12:48 PM Xueming Shen <
>>> xueming.s...@oracle.com
>>>>> 
>>>>>> wrote:
>>>>>> 
>>>>>>> +1
>>>>>>> 
>>>>>>> On 5/14/18, 8:25 AM, Jim Laskey wrote:
>>>>>>>> New string instance method that returns true if the string is
>>> empty
>>>> or
>>>>>>> contains only white space, where white space is defined as any
>>>> codepoint
>>>>>>> returns true when passed to Character::isWhitespace.
>>>>>>>> 
>>>>>>>> webrev:
>> http://cr.openjdk.java.net/~jlaskey/8200436/webrev/index.
>>>> html
>>>>>>>> jbs: https://bugs.openjdk.java.net/browse/JDK-8200436
>>>>>>>> csr: https://bugs.openjdk.java.net/browse/JDK-8200437
>>>>>>>> 
>>>>>>> 
>>>>> 
>>>> 
>>> 
>> 



Re: RFR: JDK-8200436 - String::isBlank

2018-05-15 Thread Jeremy Manson
Blank can even mean U+2422, if it comes to that.

Jeremy

On Tue, May 15, 2018 at 12:58 PM Louis Wasserman <lowas...@google.com>
wrote:

> Does this method offer significant benefits over the more general approach
> of String.codePoints().allMatch(Character::isWhitespace)?
>
> " there is a notion of all characters in > > isBlank that you do not have
> with isWhitespace."
> I'm not sure I follow.  I do tend to interpret "is this string whitespace?"
> as implying that it consists only of whitespace, whereas "blank" could mean
> "" or maybe even "___" but not obviously "   ".
>
> On Tue, May 15, 2018 at 11:19 AM Jonathan Bluett-Duncan <
> jbluettdun...@gmail.com> wrote:
>
> > How about String.isWhitespaceOrEmpty? I think that accurately describes
> the
> > method.
> >
> > Cheers,
> > Jonathan
> >
> > On 15 May 2018 at 19:15, Jeremy Manson <jeremyman...@google.com> wrote:
> >
> > > Seems to me that consistency matters here: for Character to call it
> > > whitespace and for String to call it blank is a little weird.
> > >
> > > Is there a well-understood definition of "blank string", or did this
> just
> > > seem like a good name choice?
> > >
> > > Jeremy
> > >
> > > On Mon, May 14, 2018 at 11:14 PM Remi Forax <fo...@univ-mlv.fr> wrote:
> > >
> > > > Hi Louis,
> > > > I prefer isBlank to isWhitespace, there is a notion of all characters
> > in
> > > > isBlank that you do not have with isWhitespace.
> > > >
> > > > Rémi
> > > >
> > > > - Mail original -
> > > > > De: "Louis Wasserman" <lowas...@google.com>
> > > > > À: "Xueming Shen" <xueming.s...@oracle.com>
> > > > > Cc: "core-libs-dev" <core-libs-dev@openjdk.java.net>
> > > > > Envoyé: Lundi 14 Mai 2018 22:15:50
> > > > > Objet: Re: RFR: JDK-8200436 - String::isBlank
> > > >
> > > > > It's not clear to me that "isBlank" is a good name for this method.
> > > > > "isWhitespace" might be more appropriate, perhaps.
> > > > >
> > > > > On Mon, May 14, 2018 at 12:48 PM Xueming Shen <
> > xueming.s...@oracle.com
> > > >
> > > > > wrote:
> > > > >
> > > > >> +1
> > > > >>
> > > > >> On 5/14/18, 8:25 AM, Jim Laskey wrote:
> > > > >> > New string instance method that returns true if the string is
> > empty
> > > or
> > > > >> contains only white space, where white space is defined as any
> > > codepoint
> > > > >> returns true when passed to Character::isWhitespace.
> > > > >> >
> > > > >> > webrev:
> http://cr.openjdk.java.net/~jlaskey/8200436/webrev/index.
> > > html
> > > > >> > jbs: https://bugs.openjdk.java.net/browse/JDK-8200436
> > > > >> > csr: https://bugs.openjdk.java.net/browse/JDK-8200437
> > > > >> >
> > > > >>
> > > >
> > >
> >
>


Re: RFR: JDK-8200436 - String::isBlank

2018-05-15 Thread Jonathan Bluett-Duncan
How about String.isWhitespaceOrEmpty? I think that accurately describes the
method.

Cheers,
Jonathan

On 15 May 2018 at 19:15, Jeremy Manson <jeremyman...@google.com> wrote:

> Seems to me that consistency matters here: for Character to call it
> whitespace and for String to call it blank is a little weird.
>
> Is there a well-understood definition of "blank string", or did this just
> seem like a good name choice?
>
> Jeremy
>
> On Mon, May 14, 2018 at 11:14 PM Remi Forax <fo...@univ-mlv.fr> wrote:
>
> > Hi Louis,
> > I prefer isBlank to isWhitespace, there is a notion of all characters in
> > isBlank that you do not have with isWhitespace.
> >
> > Rémi
> >
> > - Mail original -
> > > De: "Louis Wasserman" <lowas...@google.com>
> > > À: "Xueming Shen" <xueming.s...@oracle.com>
> > > Cc: "core-libs-dev" <core-libs-dev@openjdk.java.net>
> > > Envoyé: Lundi 14 Mai 2018 22:15:50
> > > Objet: Re: RFR: JDK-8200436 - String::isBlank
> >
> > > It's not clear to me that "isBlank" is a good name for this method.
> > > "isWhitespace" might be more appropriate, perhaps.
> > >
> > > On Mon, May 14, 2018 at 12:48 PM Xueming Shen <xueming.s...@oracle.com
> >
> > > wrote:
> > >
> > >> +1
> > >>
> > >> On 5/14/18, 8:25 AM, Jim Laskey wrote:
> > >> > New string instance method that returns true if the string is empty
> or
> > >> contains only white space, where white space is defined as any
> codepoint
> > >> returns true when passed to Character::isWhitespace.
> > >> >
> > >> > webrev: http://cr.openjdk.java.net/~jlaskey/8200436/webrev/index.
> html
> > >> > jbs: https://bugs.openjdk.java.net/browse/JDK-8200436
> > >> > csr: https://bugs.openjdk.java.net/browse/JDK-8200437
> > >> >
> > >>
> >
>


Re: RFR: JDK-8200436 - String::isBlank

2018-05-15 Thread Remi Forax
Hi Louis,
I prefer isBlank to isWhitespace, there is a notion of all characters in 
isBlank that you do not have with isWhitespace.

Rémi

- Mail original -
> De: "Louis Wasserman" <lowas...@google.com>
> À: "Xueming Shen" <xueming.s...@oracle.com>
> Cc: "core-libs-dev" <core-libs-dev@openjdk.java.net>
> Envoyé: Lundi 14 Mai 2018 22:15:50
> Objet: Re: RFR: JDK-8200436 - String::isBlank

> It's not clear to me that "isBlank" is a good name for this method.
> "isWhitespace" might be more appropriate, perhaps.
> 
> On Mon, May 14, 2018 at 12:48 PM Xueming Shen <xueming.s...@oracle.com>
> wrote:
> 
>> +1
>>
>> On 5/14/18, 8:25 AM, Jim Laskey wrote:
>> > New string instance method that returns true if the string is empty or
>> contains only white space, where white space is defined as any codepoint
>> returns true when passed to Character::isWhitespace.
>> >
>> > webrev: http://cr.openjdk.java.net/~jlaskey/8200436/webrev/index.html
>> > jbs: https://bugs.openjdk.java.net/browse/JDK-8200436
>> > csr: https://bugs.openjdk.java.net/browse/JDK-8200437
>> >
>>


Re: RFR: JDK-8200436 - String::isBlank

2018-05-14 Thread Sundararajan Athijegannathan

+1

-Sundar

On 14/05/18, 8:55 PM, Jim Laskey wrote:

New string instance method that returns true if the string is empty or contains 
only white space, where white space is defined as any codepoint returns true 
when passed to Character::isWhitespace.

webrev: http://cr.openjdk.java.net/~jlaskey/8200436/webrev/index.html
jbs: https://bugs.openjdk.java.net/browse/JDK-8200436
csr: https://bugs.openjdk.java.net/browse/JDK-8200437



Re: RFR: JDK-8200436 - String::isBlank

2018-05-14 Thread Xueming Shen

+1

On 5/14/18, 8:25 AM, Jim Laskey wrote:

New string instance method that returns true if the string is empty or contains 
only white space, where white space is defined as any codepoint returns true 
when passed to Character::isWhitespace.

webrev: http://cr.openjdk.java.net/~jlaskey/8200436/webrev/index.html
jbs: https://bugs.openjdk.java.net/browse/JDK-8200436
csr: https://bugs.openjdk.java.net/browse/JDK-8200437





Re: RFR: JDK-8200436 - String::isBlank

2018-05-14 Thread Paul Sandoz
+1

Paul.

> On May 14, 2018, at 8:25 AM, Jim Laskey  wrote:
> 
> New string instance method that returns true if the string is empty or 
> contains only white space, where white space is defined as any codepoint 
> returns true when passed to Character::isWhitespace.
> 
> webrev: http://cr.openjdk.java.net/~jlaskey/8200436/webrev/index.html
> jbs: https://bugs.openjdk.java.net/browse/JDK-8200436
> csr: https://bugs.openjdk.java.net/browse/JDK-8200437
>