Package com.influxdb.utils
Class Arguments
java.lang.Object
com.influxdb.utils.Arguments
Functions for parameter validation.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringcheckDuration(String string, String name) Enforces that the string is duration literal.static StringcheckDurationNotRequired(String string, String name) Enforces that the string is duration literal.static StringcheckNonEmpty(String string, String name) Enforces that the string is not empty.static voidcheckNotNegativeNumber(Number number, String name) Enforces that the number is not negative.static voidcheckNotNull(Object obj, String name) Checks that the specified object reference is notnull.static StringcheckOneCharString(String string, String name) Enforces that the string has exactly one char.static voidcheckPositiveNumber(Number number, String name) Enforces that the number is larger than 0.static voidcheckPrecision(ChronoUnit precision) Checks that the precision reference to one ofALLOWED_PRECISION.
-
Method Details
-
checkNonEmpty
Enforces that the string is not empty.- Parameters:
string- the string to testname- variable name for reporting- Returns:
string- Throws:
IllegalArgumentException- if the string is empty
-
checkOneCharString
Enforces that the string has exactly one char.- Parameters:
string- the string to testname- variable name for reporting- Returns:
string- Throws:
IllegalArgumentException- if the string has not one char
-
checkDuration
Enforces that the string is duration literal.- Parameters:
string- the string to testname- variable name for reporting- Returns:
string- Throws:
IllegalArgumentException- if the string is not duration literal
-
checkDurationNotRequired
public static String checkDurationNotRequired(String string, String name) throws IllegalArgumentException Enforces that the string is duration literal. Empty or null strings are valid.- Parameters:
string- the string to testname- variable name for reporting- Returns:
string- Throws:
IllegalArgumentException- if the string is not duration literal
-
checkPositiveNumber
Enforces that the number is larger than 0.- Parameters:
number- the number to testname- variable name for reporting- Throws:
IllegalArgumentException- if the number is less or equal to 0
-
checkNotNegativeNumber
public static void checkNotNegativeNumber(Number number, String name) throws IllegalArgumentException Enforces that the number is not negative.- Parameters:
number- the number to testname- variable name for reporting- Throws:
IllegalArgumentException- if the number is less or equal to 0
-
checkNotNull
Checks that the specified object reference is notnull.- Parameters:
obj- the object reference to check for nullityname- variable name for reporting- Throws:
NullPointerException- if the object isnull- See Also:
-
checkPrecision
Checks that the precision reference to one ofALLOWED_PRECISION.- Throws:
IllegalArgumentException- if the object is not one ofALLOWED_PRECISION
-