If we open that Pandora's box, then I want to add:

- File, empty if length is 0
- Path, empty if name length is 0
- Buffer, what?
- StringBuffer
- StringBuilder
- java.sql.Clob
- java.sql.Lob
- The content of an AtomicReference
- ZipFile
- on and on for anything that has a "size()" or "length" or "length()"

?

Gary


On Fri, Aug 17, 2018 at 2:43 AM Alexander Tsvetkov <
alexander.tsvetkov...@gmail.com> wrote:

> 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/2ac23badee02697c5eb87c46f955387b32a0d581/spring-core/src/main/java/org/springframework/util/ObjectUtils.java#L134
> ),
> 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:
> https://issues.apache.org/jira/browse/LANG-1411
> https://github.com/apache/commons-lang/pull/342
>
> Best regards,
> Alexander
>

Reply via email to