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 intbetween(byte value, String name, byte minValue, byte maxValue)Checks if the givenvalueis betweenminValueandmaxValueinclusive and throws a customizedIllegalArgumentExceptionif it is NOT.static intbetween(int value, int minValue, int maxValue)Checks if the givenvalueis betweenminValueandmaxValueinclusive and throws a customizedIllegalArgumentExceptionif it is NOT.static intbetween(int value, String name, int minValue, int maxValue)Checks if the givenvalueis betweenminValueandmaxValueinclusive and throws a customizedIllegalArgumentExceptionif it is NOT.static longbetween(long value, long minValue, long maxValue)Checks if the givenvalueis betweenminValueandmaxValueinclusive and throws a customizedIllegalArgumentExceptionif it is NOT.static longbetween(long value, String name, long minValue, long maxValue)Checks if the givenvalueis betweenminValueandmaxValueinclusive and throws a customizedIllegalArgumentExceptionif it is NOT.static BigDecimalbetween(BigDecimal value, String name, BigDecimal minValue, BigDecimal maxValue)Checks if the givenvalueis betweenminValueandmaxValue*exclusive* and throws a customizedIllegalArgumentExceptionif it is NOT.static BigDecimalbetween(BigDecimal value, BigDecimal minValue, BigDecimal maxValue)Checks if the givenvalueis betweenminValueandmaxValue*exclusive* and throws a customizedIllegalArgumentExceptionif it is NOT.static BigIntegerbetween(BigInteger value, String name, BigInteger minValue, BigInteger maxValue)Checks if the givenvalueis betweenminValueandmaxValueinclusive and throws a customizedIllegalArgumentExceptionif it is NOT.static BigIntegerbetween(BigInteger value, BigInteger minValue, BigInteger maxValue)Checks if the givenvalueis betweenminValueandmaxValueinclusive and throws a customizedIllegalArgumentExceptionif it is NOT.static booleanisNullOrBlank(CharSequence value)Checks if the given string is null, empty string or a string only contains white spaces.static booleanisNullOrEmpty(CharSequence value)Checks if the given string is null or empty.static StringnonBlank(String value, String name)Checks if the given string is notnull, empty or blank and throws a customizedIllegalArgumentExceptionif it is.static StringnonEmpty(String value, String name)Checks if the given string is neithernullnor empty and throws a customizedIllegalArgumentExceptionif it is.static <T> TnonNull(T value, String name)Checks if the given object is NOTnulland throws a customizedIllegalArgumentExceptionif it is.static intnotLessThan(int value, String name, int minValue)Checks if the givenvalueis NOT less thanminValueand throws a customizedIllegalArgumentExceptionif it is.static longnotLessThan(long value, String name, long minValue)Checks if the givenvalueis NOT less thanminValueand throws a customizedIllegalArgumentExceptionif it is.static BigIntegernotLessThan(BigInteger value, String name, BigInteger minValue)Checks if the givenvalueis NOT less thanminValueand throws a customizedIllegalArgumentExceptionif it is.static byte[]notLongerThan(byte[] value, String name, int maxLength)Checks if length of the given byte array is NOT greater thanlengthand throws a customizedIllegalArgumentExceptionif it is.static byte[]notWithDifferentLength(byte[] value, int expectedLength)Checks if length of the given byte array is NOT different fromexpectedLengthand throws a customizedIllegalArgumentExceptionif it is.static byte[]notWithDifferentLength(byte[] value, String name, int expectedLength)Checks if length of the given byte array is NOT different fromexpectedLengthand throws a customizedIllegalArgumentExceptionif it is.static StringnotWithDifferentLength(String value, int expectedLength)static StringnotWithDifferentLength(String value, Charset charset, int expectedLength)static StringnotWithDifferentLength(String value, Charset charset, String name, int expectedLength)Checks if byte length of the given string is NOT different fromexpectedLengthand throws a customizedIllegalArgumentExceptionif it is.
-
-
-
Method Detail
-
between
public static int between(int value, int minValue, int maxValue)Checks if the givenvalueis betweenminValueandmaxValueinclusive and throws a customizedIllegalArgumentExceptionif 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 thevalueis NOT betweenminValueandmaxValue
-
between
public static long between(long value, long minValue, long maxValue)Checks if the givenvalueis betweenminValueandmaxValueinclusive and throws a customizedIllegalArgumentExceptionif 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 thevalueis NOT betweenminValueandmaxValue
-
between
public static int between(byte value, String name, byte minValue, byte maxValue)Checks if the givenvalueis betweenminValueandmaxValueinclusive and throws a customizedIllegalArgumentExceptionif 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 thevalueis NOT betweenminValueandmaxValue
-
between
public static int between(int value, String name, int minValue, int maxValue)Checks if the givenvalueis betweenminValueandmaxValueinclusive and throws a customizedIllegalArgumentExceptionif 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 thevalueis NOT betweenminValueandmaxValue
-
between
public static long between(long value, String name, long minValue, long maxValue)Checks if the givenvalueis betweenminValueandmaxValueinclusive and throws a customizedIllegalArgumentExceptionif 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 thevalueis NOT betweenminValueandmaxValue
-
between
public static BigInteger between(BigInteger value, BigInteger minValue, BigInteger maxValue)
Checks if the givenvalueis betweenminValueandmaxValueinclusive and throws a customizedIllegalArgumentExceptionif 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 thevalueis NOT betweenminValueandmaxValue
-
between
public static BigInteger between(BigInteger value, String name, BigInteger minValue, BigInteger maxValue)
Checks if the givenvalueis betweenminValueandmaxValueinclusive and throws a customizedIllegalArgumentExceptionif 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 thevalueis NOT betweenminValueandmaxValue
-
between
public static BigDecimal between(BigDecimal value, BigDecimal minValue, BigDecimal maxValue)
Checks if the givenvalueis betweenminValueandmaxValue*exclusive* and throws a customizedIllegalArgumentExceptionif 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 thevalueis NOT betweenminValueandmaxValue
-
between
public static BigDecimal between(BigDecimal value, String name, BigDecimal minValue, BigDecimal maxValue)
Checks if the givenvalueis betweenminValueandmaxValue*exclusive* and throws a customizedIllegalArgumentExceptionif 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 thevalueis NOT betweenminValueandmaxValue
-
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 customizedIllegalArgumentExceptionif 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 neithernullnor empty and throws a customizedIllegalArgumentExceptionif 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 NOTnulland throws a customizedIllegalArgumentExceptionif 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 givenvalueis NOT less thanminValueand throws a customizedIllegalArgumentExceptionif 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 thevalueis less thanminValue
-
notLessThan
public static long notLessThan(long value, String name, long minValue)Checks if the givenvalueis NOT less thanminValueand throws a customizedIllegalArgumentExceptionif 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 thevalueis less thanminValue
-
notLessThan
public static BigInteger notLessThan(BigInteger value, String name, BigInteger minValue)
Checks if the givenvalueis NOT less thanminValueand throws a customizedIllegalArgumentExceptionif 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 thevalueis less thanminValue
-
notLongerThan
public static byte[] notLongerThan(byte[] value, String name, int maxLength)Checks if length of the given byte array is NOT greater thanlengthand throws a customizedIllegalArgumentExceptionif 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 fromexpectedLengthand throws a customizedIllegalArgumentExceptionif 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 fromexpectedLengthand throws a customizedIllegalArgumentExceptionif 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 fromexpectedLengthand throws a customizedIllegalArgumentExceptionif 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
-
-