juneau-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clr-apache <...@git.apache.org>
Subject [GitHub] incubator-juneau pull request #2: related to JUNEAU-49 and its inclusion via...
Date Tue, 30 May 2017 01:30:31 GMT
Github user clr-apache commented on a diff in the pull request:

    --- 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. 
    I like the simple 
    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.

View raw message