Class DriverUtils
- java.lang.Object
-
- org.apache.flink.table.jdbc.utils.DriverUtils
-
public class DriverUtils extends Object
Utils methods are copied from flink-core for flink jdbc driver to avoid excessive dependency.
-
-
Constructor Summary
Constructors Constructor Description DriverUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcheckArgument(boolean condition, Object errorMessage)Checks the given boolean condition, and throws anIllegalArgumentExceptionif the condition is not met (evaluates tofalse).static <T> TcheckNotNull(T reference, String errorMessage)Ensures that the given object reference is not null.static Map<String,String>fromProperties(Properties properties)Generate map from given properties.static booleanisNullOrWhitespaceOnly(String str)Checks if the string is null, empty, or contains only whitespace characters.
-
-
-
Method Detail
-
checkNotNull
public static <T> T checkNotNull(@Nullable T reference, @Nullable String errorMessage)
Ensures that the given object reference is not null. Upon violation, aNullPointerExceptionwith the given message is thrown.- Parameters:
reference- The object referenceerrorMessage- The message for theNullPointerExceptionthat is thrown if the check fails.- Returns:
- The object reference itself (generically typed).
- Throws:
NullPointerException- Thrown, if the passed reference was null.
-
checkArgument
public static void checkArgument(boolean condition, @Nullable Object errorMessage)Checks the given boolean condition, and throws anIllegalArgumentExceptionif the condition is not met (evaluates tofalse). The exception will have the given error message.- Parameters:
condition- The condition to checkerrorMessage- The message for theIllegalArgumentExceptionthat is thrown if the check fails.- Throws:
IllegalArgumentException- Thrown, if the condition is violated.
-
isNullOrWhitespaceOnly
public static boolean isNullOrWhitespaceOnly(String str)
Checks if the string is null, empty, or contains only whitespace characters. A whitespace character is defined viaCharacter.isWhitespace(char).- Parameters:
str- The string to check- Returns:
- True, if the string is null or blank, false otherwise.
-
fromProperties
public static Map<String,String> fromProperties(Properties properties)
Generate map from given properties.- Parameters:
properties- the given properties- Returns:
- the result map
-
-