本文整理了Java中org.apache.commons.lang3.StringUtils.containsWhitespace()
方法的一些代码示例,展示了StringUtils.containsWhitespace()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StringUtils.containsWhitespace()
方法的具体详情如下:
包路径:org.apache.commons.lang3.StringUtils
类名称:StringUtils
方法名:containsWhitespace
[英]Check whether the given CharSequence contains any whitespace characters.
Whitespace is defined by Character#isWhitespace(char).
[中]检查给定的字符序列是否包含任何空格字符。
空格由字符#isWhitespace(char)定义。
代码示例来源:origin: twosigma/beakerx
private void checkNotWhitespaces(String path) {
if (StringUtils.containsWhitespace(path)) {
throw new RuntimeException("Can not create path with whitespace.");
}
}
代码示例来源:origin: rubenlagus/TelegramBots
@SafeVarargs
private Ability(String name, String info, Locality locality, Privacy privacy, int argNum, Consumer<MessageContext> action, Consumer<MessageContext> postAction, List<Reply> replies, Predicate<Update>... flags) {
checkArgument(!isEmpty(name), "Method name cannot be empty");
checkArgument(!containsWhitespace(name), "Method name cannot contain spaces");
checkArgument(isAlphanumeric(name), "Method name can only be alpha-numeric", name);
this.name = name;
this.info = info;
this.locality = checkNotNull(locality, "Please specify a valid locality setting. Use the Locality enum class");
this.privacy = checkNotNull(privacy, "Please specify a valid privacy setting. Use the Privacy enum class");
checkArgument(argNum >= 0, "The number of arguments the method can handle CANNOT be negative. " +
"Use the number 0 if the method ignores the arguments OR uses as many as appended");
this.argNum = argNum;
this.action = checkNotNull(action, "Method action can't be empty. Please assign a function by using .action() method");
if (postAction == null)
BotLogger.info(TAG, format("No post action was detected for method with name [%s]", name));
this.flags = ofNullable(flags).map(Arrays::asList).orElse(newArrayList());
this.postAction = postAction;
this.replies = replies;
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testContainsWhitespace() {
assertFalse( StringUtils.containsWhitespace("") );
assertTrue( StringUtils.containsWhitespace(" ") );
assertFalse( StringUtils.containsWhitespace("a") );
assertTrue( StringUtils.containsWhitespace("a ") );
assertTrue( StringUtils.containsWhitespace(" a") );
assertTrue( StringUtils.containsWhitespace("a\t") );
assertTrue( StringUtils.containsWhitespace("\n") );
}
}
代码示例来源:origin: Netflix/conductor
String paramPath = values[i].substring( 2, values[i].length() - 1 );
if (StringUtils.containsWhitespace(paramPath)) {
String message = String.format("key: %s input parameter value: %s is not valid",
key, paramPath);
代码示例来源:origin: daniellitoc/xultimate-toolkit
/**
* Check whether the given CharSequence contains any whitespace characters.
* @param seq the CharSequence to check (may be {@code null})
* @return {@code true} if the CharSequence is not empty and
* contains at least 1 whitespace character
* @see java.lang.Character#isWhitespace
* @since 3.0
*/
public static boolean containsWhitespace(CharSequence seq) {
return org.apache.commons.lang3.StringUtils.containsWhitespace(seq);
}
代码示例来源:origin: co.cask.re/dre-core
public static boolean whitespace(CharSequence seq) {
return StringUtils.containsWhitespace(seq);
}
代码示例来源:origin: xpinjection/test-driven-spring-boot
private boolean isSingleWord(String correctAuthor) {
return !StringUtils.containsWhitespace(correctAuthor);
}
代码示例来源:origin: com.anrisoftware.globalpom/globalpomutils-exec
private String quoteArgument(String argument) {
argument = argument.trim();
if (containsWhitespace(argument)) {
char q = contains(argument, DOUBLE_QUOTE_CHAR) ? SINGLE_QUOTE_CHAR
: DOUBLE_QUOTE_CHAR;
argument = format(QUOTATION_FORMAT, q, argument, q);
}
return argument;
}
代码示例来源:origin: joel-costigliola/assertj-assertions-generator
private void checkGivenPackageIsValid(String generatedAssertionsPackage) {
Validate.isTrue(isNotBlank(generatedAssertionsPackage), "The given package '%s' must not be blank", generatedAssertionsPackage);
Validate.isTrue(!containsWhitespace(generatedAssertionsPackage), "The given package '%s' must not contain blank character",
generatedAssertionsPackage);
}
代码示例来源:origin: org.openksavi.sponge/sponge-core
protected String getArgsString() {
return configuration.getArguments().stream().map(arg -> StringUtils.containsWhitespace(arg) ? String.format("\"%s\"", arg) : arg)
.collect(Collectors.joining(" "));
}
代码示例来源:origin: org.openksavi.sponge/sponge-core
protected void validateEvent(Event event) {
Validate.notNull(event, "Event must not be null");
Validate.isTrue(event.getName() != null && !event.getName().trim().isEmpty(), "Event name must not be null or empty");
Validate.isTrue(
!StringUtils.containsWhitespace(event.getName())
&& !StringUtils.containsAny(event.getName(), EngineConstants.EVENT_NAME_RESERVED_CHARS),
"Event name must not contain whitespaces or reserved characters %s", EngineConstants.EVENT_NAME_RESERVED_CHARS);
}
}
代码示例来源:origin: com.github.rvesse/airline
public CommandGroupMetadata(String name,
String description,
boolean hidden,
Iterable<OptionMetadata> options,
Iterable<CommandGroupMetadata> subGroups,
CommandMetadata defaultCommand,
Iterable<CommandMetadata> commands) {
//@formatter:on
if (StringUtils.isEmpty(name))
throw new IllegalArgumentException("Group name may not be null/empty");
if (StringUtils.containsWhitespace(name))
throw new IllegalArgumentException("Group name may not contain whitespace");
this.name = name;
this.description = description;
this.hidden = hidden;
this.options = AirlineUtils.unmodifiableListCopy(options);
this.subGroups = AirlineUtils.listCopy(subGroups);
this.defaultCommand = defaultCommand;
this.commands = AirlineUtils.listCopy(commands);
if (this.defaultCommand != null && !this.commands.contains(this.defaultCommand)) {
this.commands.add(this.defaultCommand);
}
}
代码示例来源:origin: cloudfoundry-incubator/credhub
@Test
public void special_includesOnlySpecialCharacters() {
final String specialCharacters = CredHubCharacterData.SPECIAL.getCharacters();
assertThat(specialCharacters.contains("$"), equalTo(true));
assertThat(specialCharacters.contains("!"), equalTo(true));
assertThat(specialCharacters.matches("[^a-zA-Z0-9]"), equalTo(false));
assertThat(StringUtils.containsWhitespace(specialCharacters), equalTo(false));
}
代码示例来源:origin: com.github.rvesse/airline
Iterable<CommandMetadata> commands) {
if (StringUtils.containsWhitespace(name)) {
String[] names = StringUtils.split(name);
name = names[names.length - 1];
代码示例来源:origin: com.erudika/para-server
/**
* Updates the table settings (read and write capacities).
* @param appid name of the {@link com.erudika.para.core.App}
* @param readCapacity read capacity
* @param writeCapacity write capacity
* @return true if updated
*/
public static boolean updateTable(String appid, long readCapacity, long writeCapacity) {
if (StringUtils.isBlank(appid) || StringUtils.containsWhitespace(appid)) {
return false;
}
String table = getTableNameForAppid(appid);
try {
// AWS throws an exception if the new read/write capacity values are the same as the current ones
getClient().updateTable(new UpdateTableRequest().withTableName(table).
withProvisionedThroughput(new ProvisionedThroughput(readCapacity, writeCapacity)));
return true;
} catch (Exception e) {
logger.error("Could not update table '{}' - table is not active or no change to capacity: {}",
table, e.getMessage());
}
return false;
}
代码示例来源:origin: Erudika/para
/**
* Updates the table settings (read and write capacities).
* @param appid name of the {@link com.erudika.para.core.App}
* @param readCapacity read capacity
* @param writeCapacity write capacity
* @return true if updated
*/
public static boolean updateTable(String appid, long readCapacity, long writeCapacity) {
if (StringUtils.isBlank(appid) || StringUtils.containsWhitespace(appid)) {
return false;
}
String table = getTableNameForAppid(appid);
try {
// AWS throws an exception if the new read/write capacity values are the same as the current ones
getClient().updateTable(new UpdateTableRequest().withTableName(table).
withProvisionedThroughput(new ProvisionedThroughput(readCapacity, writeCapacity)));
return true;
} catch (Exception e) {
logger.error("Could not update table '{}' - table is not active or no change to capacity: {}",
table, e.getMessage());
}
return false;
}
代码示例来源:origin: com.erudika/para
/**
* Updates the table settings (read and write capacities)
* @param appid name of the {@link com.erudika.para.core.App}
* @param readCapacity read capacity
* @param writeCapacity write capacity
* @return true if updated
*/
public static boolean updateTable(String appid, Long readCapacity, Long writeCapacity) {
if (StringUtils.isBlank(appid) || StringUtils.containsWhitespace(appid) || existsTable(appid)) {
return false;
}
try {
getClient().updateTable(new UpdateTableRequest().withTableName(getTablNameForAppid(appid)).
withProvisionedThroughput(new ProvisionedThroughput(readCapacity, writeCapacity)));
} catch (Exception e) {
logger.error(null, e);
return false;
}
return true;
}
代码示例来源:origin: Erudika/para
if (StringUtils.isBlank(appid)) {
return false;
} else if (StringUtils.containsWhitespace(appid)) {
logger.warn("DynamoDB table name contains whitespace. The name '{}' is invalid.", appid);
return false;
代码示例来源:origin: com.erudika/para-server
if (StringUtils.isBlank(appid)) {
return false;
} else if (StringUtils.containsWhitespace(appid)) {
logger.warn("DynamoDB table name contains whitespace. The name '{}' is invalid.", appid);
return false;
代码示例来源:origin: com.erudika/para
/**
* Creates a table in AWS DynamoDB.
* @param appid name of the {@link com.erudika.para.core.App}
* @param readCapacity read capacity
* @param writeCapacity write capacity
* @return true if created
*/
public static boolean createTable(String appid, Long readCapacity, Long writeCapacity) {
if (StringUtils.isBlank(appid) || StringUtils.containsWhitespace(appid) || existsTable(appid)) {
return false;
}
try {
getClient().createTable(new CreateTableRequest().withTableName(getTablNameForAppid(appid)).
withKeySchema(new KeySchemaElement(Config._KEY, KeyType.HASH)).
withAttributeDefinitions(new AttributeDefinition().withAttributeName(Config._KEY).
withAttributeType(ScalarAttributeType.S)).
withProvisionedThroughput(new ProvisionedThroughput(readCapacity, writeCapacity)));
} catch (Exception e) {
logger.error(null, e);
return false;
}
return true;
}
内容来源于网络,如有侵权,请联系作者删除!