commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Henri Yandell <>
Subject [LANG] Null-protection methods
Date Thu, 09 Apr 2009 08:43:43 GMT
Is the following worth keeping in Lang?

public Foo someJdkMethod(Object input) {
    if(input == null) {
    return input.jdkMethod();

I feel that we've bloated up with these methods, and is it really
worth it? I still have lots of if(x != null && x.callFoo()) type
invocations, having a small handful of methods available in Lang to
let me say if(FooUtils.callFoo(x)) isn't enough to hide all of the
other times when I might have to worry about it.

Personally I'd like to see these methods removed from Lang [especially
given Stephen's blogging about null protected setting in some future

An example:

    public static String trim(String str) {
        return str == null ? null : str.trim();

Given that I'm likely to do N things to the string, chances are I'll
check for null up front and then invoke methods rather than repeatedly
writing ugly code by using StringUtils.

Any thoughts in favour of these methods?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message