What if
public class Foo { public static String foo(String test) { String result = test != null ? test : null; return result; } }