[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[LANG] Adding isEmpty and isNotEmpty methods to ObjectUtils

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
but I think it would be helpful to people (myself and my team included) if
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?

I've opened a JIRA ticket and a GitHub pull request as well:

Best regards,