Class InputValidationUtils
java.lang.Object
com.bonitasoft.processbuilder.extension.InputValidationUtils
Utility class for common input parameter validation checks (e.g., positive numbers, non-null values)
typically used within Bonita connectors.
NOTE: This utility assumes the calling class has an accessible 'getInputParameter(String name)' method.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckPositiveIntegerInput(String inputName, Supplier<Object> inputGetter) Checks if a given input parameter is a positive Integer.static voidcheckPositiveLongInput(String inputName, Supplier<Object> inputGetter) Checks if a given input parameter is a positive Long.static LongparseStringToLong(String input, String paramName) Parses a String input to a Long value with comprehensive validation and logging.parseStringToPositiveLong(String input, String paramName) Parses a String input to a positive Long value with comprehensive validation and logging.
-
Method Details
-
parseStringToPositiveLong
Parses a String input to a positive Long value with comprehensive validation and logging.This method handles various edge cases for String-to-Long conversion:
- If input is
null→ returnsOptional.empty() - If trimmed input is empty or equals "null" (case-insensitive) → returns
Optional.empty() - If parsing fails (NumberFormatException) → returns
Optional.empty() - If parsed value is not positive (≤ 0) → returns
Optional.empty() - If valid positive Long → returns
Optional.of(value)
All validation failures are logged with appropriate level (debug for null/empty, warn for invalid values).
- Parameters:
input- the String value to parse (may be null)paramName- the parameter name for logging purposes (used in log messages)- Returns:
- an
Optional<Long>containing the positive Long value if valid, orOptional.empty()if the input is null, empty, "null", unparseable, or not positive
- If input is
-
parseStringToLong
Parses a String input to a Long value with comprehensive validation and logging.This method handles various edge cases for String-to-Long conversion:
- If input is
null→ returnsnull - If trimmed input is empty or equals "null" (case-insensitive) → returns
null - If parsing fails (NumberFormatException) → returns
0L - If valid number → returns the parsed Long value
All validation failures are logged with appropriate level (debug for null/empty, error for parse failures).
Usage Example:
Long actionIdLong = InputValidationUtils.parseStringToLong(actionPersistenceIdInput, "actionPersistenceIdInput"); if (actionIdLong == null || actionIdLong <= 0L) { logger.warn("Invalid input: '{}' is null or not positive.", "actionPersistenceIdInput"); return Collections.emptyList(); }- Parameters:
input- the String value to parse (may be null)paramName- the parameter name for logging purposes (used in log messages)- Returns:
- the parsed Long value,
nullif input is null/empty/"null", or0Lif the input cannot be parsed as a number
- If input is
-
checkPositiveIntegerInput
public static void checkPositiveIntegerInput(String inputName, Supplier<Object> inputGetter) throws org.bonitasoft.engine.connector.ConnectorValidationException Checks if a given input parameter is a positive Integer.- Parameters:
inputName- The name of the input parameter.inputGetter- A functional interface (Supplier) to retrieve the input parameter value.- Throws:
org.bonitasoft.engine.connector.ConnectorValidationException- if the parameter is not a positive Integer.
-
checkPositiveLongInput
public static void checkPositiveLongInput(String inputName, Supplier<Object> inputGetter) throws org.bonitasoft.engine.connector.ConnectorValidationException Checks if a given input parameter is a positive Long.- Parameters:
inputName- The name of the input parameter.inputGetter- A functional interface (Supplier) to retrieve the input parameter value.- Throws:
org.bonitasoft.engine.connector.ConnectorValidationException- if the parameter is not a positive Long.
-