/** * Check that the string is not empty, is not null, and does not contain only whitespace. * * @param argument String * @param name The name of the argument * @throws IllegalArgumentException If string is null or empty */ public static void isNotEmpty( String argument, String name ) { isNotZeroLength(argument, name); if (argument != null && argument.trim().length() == 0) { throw new IllegalArgumentException(CommonI18n.argumentMayNotBeNullOrZeroLengthOrEmpty.text(name)); } }
/** * Check that the string is not empty, is not null, and does not contain only whitespace. * * @param argument String * @param name The name of the argument * @throws IllegalArgumentException If string is null or empty */ public static void isNotEmpty( String argument, String name ) { isNotZeroLength(argument, name); if (argument != null && argument.trim().length() == 0) { throw new IllegalArgumentException(CommonI18n.argumentMayNotBeNullOrZeroLengthOrEmpty.text(name)); } }
/** * Check that the string is not empty, is not null, and does not contain only whitespace. * * @param argument String * @param name The name of the argument * @throws IllegalArgumentException If string is null or empty */ public static void isNotEmpty( String argument, String name ) { isNotZeroLength(argument, name); if (argument != null && argument.trim().length() == 0) { throw new IllegalArgumentException(CommonI18n.argumentMayNotBeNullOrZeroLengthOrEmpty.text(name)); } }
@Test public void isNotZeroLengthShouldNotThrowExceptionIfGivenAStringWithOnlyWhitespace() { CheckArg.isNotZeroLength(" ", "test"); CheckArg.isNotZeroLength("\t\t", "test"); }
@Test( expected = IllegalArgumentException.class ) public void isNotZeroLengthShouldThrowExceptionIfGivenAStringWithNoCharacters() { CheckArg.isNotZeroLength("", "test"); }
@Test( expected = IllegalArgumentException.class ) public void isNotZeroLengthShouldThrowExceptionIfGivenANullString() { CheckArg.isNotZeroLength(null, "test"); }
@Test public void isNotZeroLengthShouldNotThrowExceptionIfGivenAStringOneCharacterOrLonger() { CheckArg.isNotZeroLength("a", "test"); }
@Override public void removeMixin( String mixinName ) throws NoSuchNodeTypeException, VersionException, ConstraintViolationException, LockException, RepositoryException { CheckArg.isNotZeroLength(mixinName, "mixinName");
@Override public void removeMixin( String mixinName ) throws NoSuchNodeTypeException, VersionException, ConstraintViolationException, LockException, RepositoryException { CheckArg.isNotZeroLength(mixinName, "mixinName");
@Override public void addMixin( String mixinName ) throws NoSuchNodeTypeException, VersionException, ConstraintViolationException, LockException, RepositoryException { CheckArg.isNotZeroLength(mixinName, "mixinName");
@Override public void addMixin( String mixinName ) throws NoSuchNodeTypeException, VersionException, ConstraintViolationException, LockException, RepositoryException { CheckArg.isNotZeroLength(mixinName, "mixinName");
@Override public void setPrimaryType( String nodeTypeName ) throws NoSuchNodeTypeException, VersionException, ConstraintViolationException, LockException, RepositoryException { CheckArg.isNotZeroLength(nodeTypeName, "nodeTypeName");
@Override public void setPrimaryType( String nodeTypeName ) throws NoSuchNodeTypeException, VersionException, ConstraintViolationException, LockException, RepositoryException { CheckArg.isNotZeroLength(nodeTypeName, "nodeTypeName");