Package com.clickhouse.client
Class ClickHouseChecker
- java.lang.Object
-
- com.clickhouse.client.ClickHouseChecker
-
public final class ClickHouseChecker extends Object
Utility class for validation.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
between(byte value, String name, byte minValue, byte maxValue)
Checks if the givenvalue
is betweenminValue
andmaxValue
inclusive and throws a customizedIllegalArgumentException
if it is NOT.static int
between(int value, int minValue, int maxValue)
Checks if the givenvalue
is betweenminValue
andmaxValue
inclusive and throws a customizedIllegalArgumentException
if it is NOT.static int
between(int value, String name, int minValue, int maxValue)
Checks if the givenvalue
is betweenminValue
andmaxValue
inclusive and throws a customizedIllegalArgumentException
if it is NOT.static long
between(long value, long minValue, long maxValue)
Checks if the givenvalue
is betweenminValue
andmaxValue
inclusive and throws a customizedIllegalArgumentException
if it is NOT.static long
between(long value, String name, long minValue, long maxValue)
Checks if the givenvalue
is betweenminValue
andmaxValue
inclusive and throws a customizedIllegalArgumentException
if it is NOT.static BigDecimal
between(BigDecimal value, String name, BigDecimal minValue, BigDecimal maxValue)
Checks if the givenvalue
is betweenminValue
andmaxValue
*exclusive* and throws a customizedIllegalArgumentException
if it is NOT.static BigDecimal
between(BigDecimal value, BigDecimal minValue, BigDecimal maxValue)
Checks if the givenvalue
is betweenminValue
andmaxValue
*exclusive* and throws a customizedIllegalArgumentException
if it is NOT.static BigInteger
between(BigInteger value, String name, BigInteger minValue, BigInteger maxValue)
Checks if the givenvalue
is betweenminValue
andmaxValue
inclusive and throws a customizedIllegalArgumentException
if it is NOT.static BigInteger
between(BigInteger value, BigInteger minValue, BigInteger maxValue)
Checks if the givenvalue
is betweenminValue
andmaxValue
inclusive and throws a customizedIllegalArgumentException
if it is NOT.static boolean
isNullOrBlank(CharSequence value)
Checks if the given string is null, empty string or a string only contains white spaces.static boolean
isNullOrEmpty(CharSequence value)
Checks if the given string is null or empty.static String
nonBlank(String value, String name)
Checks if the given string is notnull
, empty or blank and throws a customizedIllegalArgumentException
if it is.static String
nonEmpty(String value, String name)
Checks if the given string is neithernull
nor empty and throws a customizedIllegalArgumentException
if it is.static <T> T
nonNull(T value, String name)
Checks if the given object is NOTnull
and throws a customizedIllegalArgumentException
if it is.static int
notLessThan(int value, String name, int minValue)
Checks if the givenvalue
is NOT less thanminValue
and throws a customizedIllegalArgumentException
if it is.static long
notLessThan(long value, String name, long minValue)
Checks if the givenvalue
is NOT less thanminValue
and throws a customizedIllegalArgumentException
if it is.static BigInteger
notLessThan(BigInteger value, String name, BigInteger minValue)
Checks if the givenvalue
is NOT less thanminValue
and throws a customizedIllegalArgumentException
if it is.static byte[]
notLongerThan(byte[] value, String name, int maxLength)
Checks if length of the given byte array is NOT greater thanlength
and throws a customizedIllegalArgumentException
if it is.static byte[]
notWithDifferentLength(byte[] value, int expectedLength)
Checks if length of the given byte array is NOT different fromexpectedLength
and throws a customizedIllegalArgumentException
if it is.static byte[]
notWithDifferentLength(byte[] value, String name, int expectedLength)
Checks if length of the given byte array is NOT different fromexpectedLength
and throws a customizedIllegalArgumentException
if it is.static String
notWithDifferentLength(String value, int expectedLength)
static String
notWithDifferentLength(String value, Charset charset, int expectedLength)
static String
notWithDifferentLength(String value, Charset charset, String name, int expectedLength)
Checks if byte length of the given string is NOT different fromexpectedLength
and throws a customizedIllegalArgumentException
if it is.
-
-
-
Method Detail
-
between
public static int between(int value, int minValue, int maxValue)
Checks if the givenvalue
is betweenminValue
andmaxValue
inclusive and throws a customizedIllegalArgumentException
if it is NOT.- Parameters:
value
- the value to checkminValue
- minimum value to compare withmaxValue
- maximum value to compare with- Returns:
- the exact same value
- Throws:
IllegalArgumentException
- if thevalue
is NOT betweenminValue
andmaxValue
-
between
public static long between(long value, long minValue, long maxValue)
Checks if the givenvalue
is betweenminValue
andmaxValue
inclusive and throws a customizedIllegalArgumentException
if it is NOT.- Parameters:
value
- the value to checkminValue
- minimum value to compare withmaxValue
- maximum value to compare with- Returns:
- the exact same value
- Throws:
IllegalArgumentException
- if thevalue
is NOT betweenminValue
andmaxValue
-
between
public static int between(byte value, String name, byte minValue, byte maxValue)
Checks if the givenvalue
is betweenminValue
andmaxValue
inclusive and throws a customizedIllegalArgumentException
if it is NOT.- Parameters:
value
- the value to checkname
- name of the valueminValue
- minimum value to compare withmaxValue
- maximum value to compare with- Returns:
- the exact same value
- Throws:
IllegalArgumentException
- if thevalue
is NOT betweenminValue
andmaxValue
-
between
public static int between(int value, String name, int minValue, int maxValue)
Checks if the givenvalue
is betweenminValue
andmaxValue
inclusive and throws a customizedIllegalArgumentException
if it is NOT.- Parameters:
value
- the value to checkname
- name of the valueminValue
- minimum value to compare withmaxValue
- maximum value to compare with- Returns:
- the exact same value
- Throws:
IllegalArgumentException
- if thevalue
is NOT betweenminValue
andmaxValue
-
between
public static long between(long value, String name, long minValue, long maxValue)
Checks if the givenvalue
is betweenminValue
andmaxValue
inclusive and throws a customizedIllegalArgumentException
if it is NOT.- Parameters:
value
- the value to checkname
- name of the valueminValue
- minimum value to compare withmaxValue
- maximum value to compare with- Returns:
- the exact same value
- Throws:
IllegalArgumentException
- if thevalue
is NOT betweenminValue
andmaxValue
-
between
public static BigInteger between(BigInteger value, BigInteger minValue, BigInteger maxValue)
Checks if the givenvalue
is betweenminValue
andmaxValue
inclusive and throws a customizedIllegalArgumentException
if it is NOT.- Parameters:
value
- the value to checkminValue
- minimum value to compare withmaxValue
- maximum value to compare with- Returns:
- the exact same value
- Throws:
IllegalArgumentException
- if thevalue
is NOT betweenminValue
andmaxValue
-
between
public static BigInteger between(BigInteger value, String name, BigInteger minValue, BigInteger maxValue)
Checks if the givenvalue
is betweenminValue
andmaxValue
inclusive and throws a customizedIllegalArgumentException
if it is NOT.- Parameters:
value
- the value to checkname
- name of the valueminValue
- minimum value to compare withmaxValue
- maximum value to compare with- Returns:
- the exact same value
- Throws:
IllegalArgumentException
- if thevalue
is NOT betweenminValue
andmaxValue
-
between
public static BigDecimal between(BigDecimal value, BigDecimal minValue, BigDecimal maxValue)
Checks if the givenvalue
is betweenminValue
andmaxValue
*exclusive* and throws a customizedIllegalArgumentException
if it is NOT.- Parameters:
value
- the value to checkminValue
- minimum value to compare withmaxValue
- maximum value to compare with- Returns:
- the exact same value
- Throws:
IllegalArgumentException
- if thevalue
is NOT betweenminValue
andmaxValue
-
between
public static BigDecimal between(BigDecimal value, String name, BigDecimal minValue, BigDecimal maxValue)
Checks if the givenvalue
is betweenminValue
andmaxValue
*exclusive* and throws a customizedIllegalArgumentException
if it is NOT.- Parameters:
value
- the value to checkname
- name of the valueminValue
- minimum value to compare withmaxValue
- maximum value to compare with- Returns:
- the exact same value
- Throws:
IllegalArgumentException
- if thevalue
is NOT betweenminValue
andmaxValue
-
isNullOrEmpty
public static boolean isNullOrEmpty(CharSequence value)
Checks if the given string is null or empty.- Parameters:
value
- the string to check- Returns:
- true if the string is null or empty; false otherwise
-
isNullOrBlank
public static boolean isNullOrBlank(CharSequence value)
Checks if the given string is null, empty string or a string only contains white spaces.- Parameters:
value
- the string to check- Returns:
- true if the string is null, empty or blankļ¼ false otherwise
-
nonBlank
public static String nonBlank(String value, String name)
Checks if the given string is notnull
, empty or blank and throws a customizedIllegalArgumentException
if it is.- Parameters:
value
- the string to checkname
- name of the string- Returns:
- the exact same string
- Throws:
IllegalArgumentException
- if the string is null, empty or blank
-
nonEmpty
public static String nonEmpty(String value, String name)
Checks if the given string is neithernull
nor empty and throws a customizedIllegalArgumentException
if it is.- Parameters:
value
- the string to checkname
- name of the string- Returns:
- the exact same string
- Throws:
IllegalArgumentException
- if the string is null or empty
-
nonNull
public static final <T> T nonNull(T value, String name)
Checks if the given object is NOTnull
and throws a customizedIllegalArgumentException
if it is.- Type Parameters:
T
- type of the object- Parameters:
value
- the objectname
- name of the object- Returns:
- the exact same object
- Throws:
IllegalArgumentException
- if the object is null
-
notLessThan
public static int notLessThan(int value, String name, int minValue)
Checks if the givenvalue
is NOT less thanminValue
and throws a customizedIllegalArgumentException
if it is.- Parameters:
value
- the value to checkname
- name of the valueminValue
- minimum value to compare with- Returns:
- the exact same value
- Throws:
IllegalArgumentException
- if thevalue
is less thanminValue
-
notLessThan
public static long notLessThan(long value, String name, long minValue)
Checks if the givenvalue
is NOT less thanminValue
and throws a customizedIllegalArgumentException
if it is.- Parameters:
value
- the value to checkname
- name of the valueminValue
- minimum value to compare with- Returns:
- the exact same value
- Throws:
IllegalArgumentException
- if thevalue
is less thanminValue
-
notLessThan
public static BigInteger notLessThan(BigInteger value, String name, BigInteger minValue)
Checks if the givenvalue
is NOT less thanminValue
and throws a customizedIllegalArgumentException
if it is.- Parameters:
value
- the value to checkname
- name of the valueminValue
- minimum value to compare with- Returns:
- the exact same value
- Throws:
IllegalArgumentException
- if thevalue
is less thanminValue
-
notLongerThan
public static byte[] notLongerThan(byte[] value, String name, int maxLength)
Checks if length of the given byte array is NOT greater thanlength
and throws a customizedIllegalArgumentException
if it is.- Parameters:
value
- the byte array to checkname
- name of the byte arraymaxLength
- maximum length of the byte array- Returns:
- the exact same byte array
- Throws:
IllegalArgumentException
- if length of the byte array is greater thanmaxlength
-
notWithDifferentLength
public static byte[] notWithDifferentLength(byte[] value, int expectedLength)
Checks if length of the given byte array is NOT different fromexpectedLength
and throws a customizedIllegalArgumentException
if it is.- Parameters:
value
- the byte array to checkexpectedLength
- execpted length of the byte array- Returns:
- the exact same byte array
- Throws:
IllegalArgumentException
- if length of the byte array is not same asexpectedLength
-
notWithDifferentLength
public static byte[] notWithDifferentLength(byte[] value, String name, int expectedLength)
Checks if length of the given byte array is NOT different fromexpectedLength
and throws a customizedIllegalArgumentException
if it is.- Parameters:
value
- the byte array to checkname
- name of the byte arrayexpectedLength
- execpted length of the byte array- Returns:
- the exact same byte array
- Throws:
IllegalArgumentException
- if length of the byte array is not same asexpectedLength
-
notWithDifferentLength
public static String notWithDifferentLength(String value, int expectedLength)
-
notWithDifferentLength
public static String notWithDifferentLength(String value, Charset charset, int expectedLength)
-
notWithDifferentLength
public static String notWithDifferentLength(String value, Charset charset, String name, int expectedLength)
Checks if byte length of the given string is NOT different fromexpectedLength
and throws a customizedIllegalArgumentException
if it is.- Parameters:
value
- the string to checkcharset
- charset used to decode the string for byte length comparison, null means utf8name
- name of the byte arrayexpectedLength
- execpted length of the string- Returns:
- the exact same string
- Throws:
IllegalArgumentException
- if length of the byte array is not same asexpectedLength
-
-