Class Parameters

java.lang.Object
io.dingodb.sdk.common.utils.Parameters

public final class Parameters extends Object
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> T
    check(T input, Predicate<T> checkFunction, String message)
    If check function return is false, throw exception, else return input.
    static <T> T
    check(T input, Predicate<T> checkFunction, Supplier<RuntimeException> throwableSupplier)
    If check function return is false, throw exception, else return input.
    static <T> T
    clean(T input, Predicate<T> checkFunction, Supplier<T> valueSupplier)
    If check function return is false, return default value, else return input.
    static <T> T
    clean(T input, Predicate<T> checkFunction, T defaultValue)
    If check function return is false, return default value, else return input.
    static <T> T
    cleanNull(T input, Supplier<T> valueSupplier)
    If check function return is false, return default value, else return input.
    static <T> T
    cleanNull(T input, T defaultValue)
    If check function return is false, return default value, else return input.
    static <T> @NonNull T
    nonNull(T input, String message)
    If input is null, throw NullPointerException, else return input.
    static <E, C extends Collection<E>>
    @NonNull C
    notEmpty(C input, String message)
    If input is null or empty, throw IllegalArgumentException, else return input.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • nonNull

      public static <T> @NonNull T nonNull(T input, String message)
      If input is null, throw NullPointerException, else return input.
      Type Parameters:
      T - input type
      Parameters:
      input - check object
      message - exception message if input is null
      Returns:
      input
    • notEmpty

      public static <E, C extends Collection<E>> @NonNull C notEmpty(C input, String message)
      If input is null or empty, throw IllegalArgumentException, else return input.
      Type Parameters:
      C - input collection type
      Parameters:
      input - check object
      message - exception message if input is null
      Returns:
      input
    • check

      public static <T> T check(T input, Predicate<T> checkFunction, String message)
      If check function return is false, throw exception, else return input.
      Type Parameters:
      T - input type
      Parameters:
      input - check object
      checkFunction - check function
      message - error message
      Returns:
      input
    • check

      public static <T> T check(T input, Predicate<T> checkFunction, Supplier<RuntimeException> throwableSupplier)
      If check function return is false, throw exception, else return input.
      Type Parameters:
      T - input type
      Parameters:
      input - check object
      checkFunction - check function
      throwableSupplier - throwable supplier
      Returns:
      input
    • cleanNull

      public static <T> T cleanNull(T input, T defaultValue)
      If check function return is false, return default value, else return input.
      Type Parameters:
      T - input type
      Parameters:
      input - check object
      defaultValue - default value
      Returns:
      input
    • cleanNull

      public static <T> T cleanNull(T input, Supplier<T> valueSupplier)
      If check function return is false, return default value, else return input.
      Type Parameters:
      T - input type
      Parameters:
      input - check object
      valueSupplier - default value supplier
      Returns:
      input
    • clean

      public static <T> T clean(T input, Predicate<T> checkFunction, Supplier<T> valueSupplier)
      If check function return is false, return default value, else return input.
      Type Parameters:
      T - input type
      Parameters:
      input - check object
      checkFunction - check function
      valueSupplier - default value supplier
      Returns:
      input
    • clean

      public static <T> T clean(T input, Predicate<T> checkFunction, T defaultValue)
      If check function return is false, return default value, else return input.
      Type Parameters:
      T - input type
      Parameters:
      input - check object
      checkFunction - check function
      defaultValue - default value supplier
      Returns:
      input