On 01/01/2020 01:13, Michael Osipov wrote: > 2. In ArtifactUtils.notBlank, replacing >> >> Validate.notBlank( str, message ); >> >> with >> >> for (int i=0; i < str.length(); i++) if >> (!Character.isWhitespace(str.charAt(i))) return; >> throw new IllegalArgumentException(message); >> >> or, using Java 8 code, >> >> if (str.chars().allMatch(Character::isWhitespace)) throw new >> IllegalArgumentException(message); > > These are not equivalient. Validate#notBlank throws NPE on null input, those > alternatives don't do. I'd has to be interface specification equal. > > M
Thanks Michael for picking that up. So should be if (str != null) for (int i=0; i < str.length(); i++) if (!Character.isWhitespace(str.charAt(i))) return; throw new IllegalArgumentException(message); or, using Java 8 code, if (str == null || str.chars().allMatch(Character::isWhitespace)) throw new IllegalArgumentException(message); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
