private static void validateTrustAllRoots(final String trustAllRoots, final List<String> validationList) { if (!BooleanUtilities.isValid(trustAllRoots)) { validationList.add(INVALID_TRUST_ALL_ROOTS); } }
private static void validateIgnoreCase(final String ignoreCase, final List<String> validationList) { if (!BooleanUtilities.isValid(ignoreCase)) { validationList.add(String.format(INVALID_IGNORE_CASE, ignoreCase)); } }
/** * If enforcedBoolean is "true" and string input is: null, empty, many empty chars, TrUe, tRuE... but not "false" * then returns "true". * If enforcedBoolean is "false" and string input is: null, empty, many empty chars, FaLsE, fAlSe... but not "true" * then returns "false" * This behavior is needed for inputs like: "imageNoReboot" when we want them to be set to "true" disregarding the * value provided (null, empty, many empty chars, TrUe, tRuE) except the case when is "false" * * @param input String to be evaluated. * @param enforcedBoolean Enforcement boolean. * @return A boolean according with above description. */ public static boolean getEnforcedBooleanCondition(String input, boolean enforcedBoolean) { return (enforcedBoolean) ? isValid(input) == parseBoolean(input) : parseBoolean(input); }
public Validator validateBoolean(@NotNull final String booleanValue, @NotNull final String inputName) { if (!isValid(booleanValue)) { errorList.add(format("[%s]: Invalid boolean value!", inputName)); } return this; }
public Validator validateBoolean(@NotNull final String booleanValue, @NotNull final String inputName) { if (!isValid(booleanValue)) { errorList.add(format("[%s]: Invalid boolean value!", inputName)); } return this; } }
public Validator validateBoolean(@NotNull final String booleanValue, @NotNull final String inputName) { if (!isValid(booleanValue)) { errorList.add(format("[%s]: Invalid boolean value!", inputName)); } return this; }
public Validator validateBooleanList(@NotNull final String booleanValueList, @NotNull final String inputName, @NotNull final String delimiter) { for (String value : booleanValueList.split(delimiter)) { if (!isValid(value)) { errorList.add(format("[%s]: Invalid boolean value - [%s].", inputName, value)); } } return this; }
/** * If enforcedBoolean is "true" and string input is: null, empty, many empty chars, TrUe, tRuE... but not "false" * then returns "true". * If enforcedBoolean is "false" and string input is: null, empty, many empty chars, FaLsE, fAlSe... but not "true" * then returns "false" * This behavior is needed for inputs like: "imageNoReboot" when we want them to be set to "true" disregarding the * value provided (null, empty, many empty chars, TrUe, tRuE) except the case when is "false" * * @param input String to be evaluated. * @param enforcedBoolean Enforcement boolean. * @return A boolean according with above description. */ private static boolean getEnforcedBooleanCondition(String input, boolean enforcedBoolean) { return (enforcedBoolean) ? isValid(input) == Boolean.parseBoolean(input) : Boolean.parseBoolean(input); } }
@NotNull private static List<String> addVerifyBoolean(@NotNull List<String> exceptions, @Nullable final String input, @NotNull final String inputName) { if (isEmpty(input)) { exceptions.add(String.format(EXCEPTION_NULL_EMPTY, inputName)); } else if (!isValid(input)) { exceptions.add(String.format(EXCEPTION_INVALID_BOOLEAN, input, inputName)); } return exceptions; }
/** * If the booleanStr is a valid boolean (see isValid) it returns the boolean value, otherwise it throws an exception * * @param booleanStr the string to convert to boolean * @return true if the booleanStr is 'true', false if it's 'false' * @throws IllegalArgumentException if the booleanStr is not a valid boolean */ public static boolean toBoolean(@Nullable final String booleanStr) { if (!isValid(booleanStr)) { throw new IllegalArgumentException(booleanStr + ExceptionValues.EXCEPTION_DELIMITER + ExceptionValues.INVALID_BOOLEAN_VALUE); } return BooleanUtils.toBoolean(getLowerCaseString(booleanStr)); }
/** * If the booleanStr is a valid boolean (see isValid) it returns the boolean value, otherwise it throws an exception * * @param booleanStr the string to convert to boolean * @return true if the booleanStr is 'true', false if it's 'false' * @throws IllegalArgumentException if the booleanStr is not a valid boolean */ public static boolean toBoolean(@Nullable final String booleanStr) { if (!isValid(booleanStr)) { throw new IllegalArgumentException(booleanStr + ExceptionValues.EXCEPTION_DELIMITER + ExceptionValues.INVALID_BOOLEAN_VALUE); } return BooleanUtils.toBoolean(getLowerCaseString(booleanStr)); }
final String pdfPassword = defaultIfEmpty(password, EMPTY); final String pdfContent = PdfParseService.getPdfContent(path, pdfPassword).trim().replace(System.lineSeparator(), EMPTY); final boolean validIgnoreCase = BooleanUtilities.isValid(ignoreCase); if (!validIgnoreCase) { throw new RuntimeException(format("Invalid boolean value for ignoreCase parameter: %s", ignoreCase));
private static List<String> validateCommonSqlInputs(String dbServerName, String dbType, String username, String password, String instance, String dbPort, String database, String authenticationType, String trustAllRoots, String trustStore, String trustStorePassword, String resultSetType, String resultSetConcurrency, String authLibraryPath) { final List<String> validationList = new ArrayList<>(); validateDbType(dbType, validationList); validateNoneEmpty(dbServerName, INVALID_DB_SERVER_NAME, validationList); if (!(AUTH_WINDOWS.equalsIgnoreCase(authenticationType) && MSSQL_DB_TYPE.equalsIgnoreCase(dbType))) { validateNoneEmpty(username, INVALID_USERNAME, validationList); validateNoneEmpty(password, INVALID_PASSWORD, validationList); } validateTrustAllRoots(trustAllRoots, validationList); validateResultSetType(resultSetType, validationList); validateResultSetConcurrency(resultSetConcurrency, validationList); validateDbPort(dbPort, validationList); if (isValidDbType(dbType)) { validateInstance(instance, dbType, validationList); validateDbName(database, dbType, validationList); validateAuthType(authenticationType, dbType, validationList); validateAuthLibraryPath(authenticationType, dbType, authLibraryPath, validationList); } if (BooleanUtilities.isValid(trustAllRoots)) { validateTrustAllRootsRequire(BooleanUtilities.toBoolean(trustAllRoots), trustStore, trustStorePassword, validationList); } return validationList; }