I have such common utility class, it looks like this:
public final class Utils {
public static <T> T forNull(T object, String objectName) {
if (object == null)
throw new NullPointerException(String.format("\"%s\" must not be null", objectName));
return object;
}
}
...and I'm wondering if it's worthy to move this string -> "\"%s\" must not be null" out of the method and declare it as static final. The method will be used frequently.
String(when it might not be)