Package org.pjdbc.validation
Class ParameterValidator
java.lang.Object
org.pjdbc.validation.ParameterValidator
Validates URL parameters against
DriverParameter annotations at runtime.
This class provides runtime validation of driver parameters using the same constraints defined in the annotations. It validates:
- Required parameters are present
- Parameter values match the declared type (INTEGER, FLOAT, BOOLEAN, STRING)
- Numeric values are within min/max bounds
- String values are in the declared enum values (if specified)
Example usage:
Map<String, String> params = getUrlParameters(url);
ParameterValidator.validate(MyDriver.class, params);
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classResult of parameter validation. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidValidates parameters against the annotations on the given driver class.validateSingle(Class<?> driverClass, String paramName, String value) Validates a single parameter value and returns the validation result.
-
Method Details
-
validate
public static void validate(Class<?> driverClass, Map<String, String> parameters) throws SQLExceptionValidates parameters against the annotations on the given driver class.- Parameters:
driverClass- the driver class with @DriverParameter annotationsparameters- the URL parameters to validate- Throws:
SQLException- if validation fails
-
validateSingle
public static ParameterValidator.ValidationResult validateSingle(Class<?> driverClass, String paramName, String value) Validates a single parameter value and returns the validation result.- Parameters:
driverClass- the driver class with @DriverParameter annotationsparamName- the parameter namevalue- the parameter value- Returns:
- validation result
-