You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@juneau.apache.org by steveblackmon <gi...@git.apache.org> on 2017/05/30 00:50:29 UTC

[GitHub] incubator-juneau pull request #2: related to JUNEAU-49 and its inclusion via...

GitHub user steveblackmon opened a pull request:

    https://github.com/apache/incubator-juneau/pull/2

    related to JUNEAU-49 and its inclusion via STREAMS-504

    

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

    $ git pull https://github.com/steveblackmon/incubator-juneau JUNEAU-49

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

    https://github.com/apache/incubator-juneau/pull/2.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 #2
    
----
commit f352d5fb9acca53497a59c1743178233967d28e0
Author: Steve Blackmon @steveblackmon <sb...@apache.org>
Date:   2017-05-30T00:48:33Z

    related to JUNEAU-49 and its inclusion via STREAMS-504

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-juneau pull request #2: related to JUNEAU-49 and its inclusion via...

Posted by clr-apache <gi...@git.apache.org>.
Github user clr-apache commented on a diff in the pull request:

    https://github.com/apache/incubator-juneau/pull/2#discussion_r118998959
  
    --- Diff: juneau-core/src/main/java/org/apache/juneau/internal/StringUtils.java ---
    @@ -618,7 +618,9 @@ public static boolean isEmpty(String s) {
     	 * @return <jk>true</jk> if specified string is <jk>null</jk> or it's {@link #toString()} method returns an empty string.
     	 */
     	public static boolean isEmpty(Object s) {
    -		return s == null || s.toString().isEmpty();
    +		if( s == null ) return true;
    +		if( s instanceof List ) return ((List) s).size() == 0;
    --- End diff --
    
    There is a big discussion on stackoverflow on this topic. 
    https://stackoverflow.com/questions/3321526/should-i-use-string-isempty-or-equalsstring
    I like the simple 
    "".equals(s)
    which handles the null case.
    
    If you include s being an instance of collection, it seems that you could use
    if (s instanceof Iterable) return (Iterable) s).isEmpty();
    Then even user-defined types that implement Iterable can be used.
    



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-juneau pull request #2: related to JUNEAU-49 and its inclusion via...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/incubator-juneau/pull/2


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-juneau pull request #2: related to JUNEAU-49 and its inclusion via...

Posted by johnament <gi...@git.apache.org>.
Github user johnament commented on a diff in the pull request:

    https://github.com/apache/incubator-juneau/pull/2#discussion_r118999207
  
    --- Diff: juneau-core/src/main/java/org/apache/juneau/internal/StringUtils.java ---
    @@ -618,7 +618,9 @@ public static boolean isEmpty(String s) {
     	 * @return <jk>true</jk> if specified string is <jk>null</jk> or it's {@link #toString()} method returns an empty string.
     	 */
     	public static boolean isEmpty(Object s) {
    -		return s == null || s.toString().isEmpty();
    +		if( s == null ) return true;
    +		if( s instanceof List ) return ((List) s).size() == 0;
    --- End diff --
    
    @clr-apache the only problem with that is `Collection` is what introduces `isEmpty()`, `Iterable` only provides a handle to the `Iterator`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-juneau pull request #2: related to JUNEAU-49 and its inclusion via...

Posted by clr-apache <gi...@git.apache.org>.
Github user clr-apache commented on a diff in the pull request:

    https://github.com/apache/incubator-juneau/pull/2#discussion_r119006240
  
    --- Diff: juneau-core/src/main/java/org/apache/juneau/internal/StringUtils.java ---
    @@ -618,7 +618,9 @@ public static boolean isEmpty(String s) {
     	 * @return <jk>true</jk> if specified string is <jk>null</jk> or it's {@link #toString()} method returns an empty string.
     	 */
     	public static boolean isEmpty(Object s) {
    -		return s == null || s.toString().isEmpty();
    +		if( s == null ) return true;
    +		if( s instanceof List ) return ((List) s).size() == 0;
    --- End diff --
    
    of course you are right. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-juneau pull request #2: related to JUNEAU-49 and its inclusion via...

Posted by clr-apache <gi...@git.apache.org>.
Github user clr-apache commented on a diff in the pull request:

    https://github.com/apache/incubator-juneau/pull/2#discussion_r118999198
  
    --- Diff: juneau-core/src/main/java/org/apache/juneau/internal/StringUtils.java ---
    @@ -618,7 +618,9 @@ public static boolean isEmpty(String s) {
     	 * @return <jk>true</jk> if specified string is <jk>null</jk> or it's {@link #toString()} method returns an empty string.
     	 */
     	public static boolean isEmpty(Object s) {
    -		return s == null || s.toString().isEmpty();
    +		if( s == null ) return true;
    +		if( s instanceof List ) return ((List) s).size() == 0;
    --- End diff --
    
    Of course, I missed the semantic that you want to return true if s is null. So you need the null check in addition to the equals or isEmpty check.
    
    Too much javascript for me I guess. :(


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-juneau pull request #2: related to JUNEAU-49 and its inclusion via...

Posted by johnament <gi...@git.apache.org>.
Github user johnament commented on a diff in the pull request:

    https://github.com/apache/incubator-juneau/pull/2#discussion_r118997472
  
    --- Diff: juneau-core/src/main/java/org/apache/juneau/internal/StringUtils.java ---
    @@ -618,7 +618,9 @@ public static boolean isEmpty(String s) {
     	 * @return <jk>true</jk> if specified string is <jk>null</jk> or it's {@link #toString()} method returns an empty string.
     	 */
     	public static boolean isEmpty(Object s) {
    -		return s == null || s.toString().isEmpty();
    +		if( s == null ) return true;
    +		if( s instanceof List ) return ((List) s).size() == 0;
    --- End diff --
    
    Would any `Collection` apply here? Or specifically `List`?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---