Class Validators
java.lang.Object
io.github.mfvanek.pg.model.validation.Validators
Utility class providing various validation methods.
This class cannot be instantiated.
-
Method Summary
Modifier and TypeMethodDescriptionstatic intargumentNotNegative(int argumentValue, String argumentName) Ensures the given integer value is not negative.static longcountNotNegative(long count, String argumentName) Ensures the given count is not negative.static StringindexNameNotBlank(String indexName) Ensures the provided index name is not blank.static StringEnsures the provided string argument is not blank.static longsizeNotNegative(long sizeInBytes, String argumentName) Ensures the given size is not negative.static StringtableNameNotBlank(String tableName) Ensures the provided table name is not blank.static <T> voidvalidateThatNotEmpty(Collection<T> columnsInConstraint) Ensures the provided list is not empty.static voidvalidateThatTableIsTheSame(String expectedTableName, Collection<? extends TableNameAware> rows) Validates that all rows have the same table name as the expected table name.static <T extends TableNameAware & DbObject>
voidvalidateThatTableIsTheSame(List<T> rows) Validates that all rows have the same table name.static doublevalidPercent(double percentValue, String argumentName) Ensures the given percent value is between 0.0 and 100.0 inclusive.static longvalueIsPositive(long argumentValue, String argumentName) Ensures the given value is positive.
-
Method Details
-
valueIsPositive
Ensures the given value is positive.- Parameters:
argumentValue- the value to checkargumentName- the name of the argument being checked- Returns:
- the provided value if it is positive
- Throws:
IllegalArgumentException- if the value is not positive
-
tableNameNotBlank
Ensures the provided table name is not blank.- Parameters:
tableName- the table name to check- Returns:
- the provided table name if it is not blank
- Throws:
IllegalArgumentException- if the table name is blank
-
indexNameNotBlank
Ensures the provided index name is not blank.- Parameters:
indexName- the index name to check- Returns:
- the provided index name if it is not blank
- Throws:
IllegalArgumentException- if the index name is blank
-
notBlank
Ensures the provided string argument is not blank.- Parameters:
argumentValue- the string argument to checkargumentName- the name of the argument being checked- Returns:
- the provided string argument if it is not blank
- Throws:
IllegalArgumentException- if the argument is blank
-
sizeNotNegative
Ensures the given size is not negative.- Parameters:
sizeInBytes- the size to checkargumentName- the name of the argument being checked- Returns:
- the provided size if it is not negative
- Throws:
IllegalArgumentException- if the size is negative
-
countNotNegative
Ensures the given count is not negative.- Parameters:
count- the count to checkargumentName- the name of the argument being checked- Returns:
- the provided count if it is not negative
- Throws:
IllegalArgumentException- if the count is negative
-
argumentNotNegative
Ensures the given integer value is not negative.- Parameters:
argumentValue- the value to checkargumentName- the name of the argument being checked- Returns:
- the provided value if it is not negative
- Throws:
IllegalArgumentException- if the value is negative
-
validateThatTableIsTheSame
public static void validateThatTableIsTheSame(String expectedTableName, Collection<? extends TableNameAware> rows) Validates that all rows have the same table name as the expected table name.- Parameters:
expectedTableName- the expected table namerows- the rows to check- Throws:
IllegalArgumentException- if any row has a different table name
-
validateThatTableIsTheSame
Validates that all rows have the same table name.- Type Parameters:
T- the type of the list elements- Parameters:
rows- the rows to check
-
validateThatNotEmpty
Ensures the provided list is not empty.- Type Parameters:
T- the type of the list elements- Parameters:
columnsInConstraint- the list to check- Throws:
IllegalArgumentException- if the list is empty
-
validPercent
Ensures the given percent value is between 0.0 and 100.0 inclusive.- Parameters:
percentValue- the percent value to checkargumentName- the name of the argument being checked- Returns:
- the provided percent value if it is valid
- Throws:
IllegalArgumentException- if the percent value is outside the valid range
-