private void checkNotWhitespaces(String path) { if (StringUtils.containsWhitespace(path)) { throw new RuntimeException("Can not create path with whitespace."); } }
@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; }
@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") ); } }
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);
/** * 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); }
public static boolean whitespace(CharSequence seq) { return StringUtils.containsWhitespace(seq); }
private boolean isSingleWord(String correctAuthor) { return !StringUtils.containsWhitespace(correctAuthor); }
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; }
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); }
protected String getArgsString() { return configuration.getArguments().stream().map(arg -> StringUtils.containsWhitespace(arg) ? String.format("\"%s\"", arg) : arg) .collect(Collectors.joining(" ")); }
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); } }
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); } }
@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)); }
Iterable<CommandMetadata> commands) { if (StringUtils.containsWhitespace(name)) { String[] names = StringUtils.split(name); name = names[names.length - 1];
/** * 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; }
/** * 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; }
/** * 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; }
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;
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;
/** * 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; }