Re: [LANG] Adding isEmpty and isNotEmpty methods to ObjectUtils
Yes, ObjectUtils.isEmpty(null) would return true. You can review the pull
request (https://github.com/apache/commons-lang/pull/342) if you'd like to
see the entire implementation in its current state.
Thanks and best regards,
2018-08-17 15:41 GMT+03:00 Benedikt Ritter <britter@xxxxxxxxxx>:
> Hello Alexander,
> welcome to the mailing list and thanks for your contribution.
> Am Fr., 17. Aug. 2018 um 10:43 Uhr schrieb Alexander Tsvetkov <
> > Hi all,
> > First of all, apologies if I have messed something up - this is my first
> > attempt at contributing to Apache.
> > With that said, I'd like to propose adding two new methods to Commons
> > Lang's ObjectUtils class:
> > - isEmpty()
> > - isNotEmpty()
> > These would check whether the object is empty (or not empty respectively)
> > based on its type:
> > - CharSequence - Considered empty if its length is zero.
> > - Array - Considered empty if its length is zero.
> > - Collection - Considered empty if it has zero elements.
> > - Map - Considered empty if it has zero key-value mappings.
> > The object would be considered "not-empty" if its type is not one of the
> > types mentioned above.
> > There is an already existing method that does exactly this in Spring's
> > ObjectUtils (see
> > https://github.com/spring-projects/spring-framework/blob/
> > ),
> > but I think it would be helpful to people (myself and my team included)
> > there was a similar method in Commons Lang's ObjectUtils. That way we
> > wouldn't have to add a dependency to Spring or re-implement the method in
> > our code base.
> > What do you think?
> sounds reasonable. How would you handle null inputs? For example
> StringUtils.isEmpty(null) == true, so I would expect the same behavior from
> > I've opened a JIRA ticket and a GitHub pull request as well:
> > https://issues.apache.org/jira/browse/LANG-1411
> > https://github.com/apache/commons-lang/pull/342
> > Best regards,
> > Alexander