public static String toString(@Nullable Object obj) {
    return obj == null ? "null" : obj.toString();
  }
Utility methods applicable to (almost) any object. Includes null-safe variants of methods on class Object.
spock-core/src/main/java/org/spockframework/util/ObjectUtil.java