Class Preconditions

java.lang.Object
com.palantir.logsafe.Preconditions

public final class Preconditions extends Object
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    checkArgument(boolean expression)
    Ensures the truth of an expression involving one or more parameters to the calling method.
    static void
    checkArgument(boolean expression, @Safe String message)
    Ensures the truth of an expression involving one or more parameters to the calling method.
    static void
    checkArgument(boolean expression, @Safe String message, com.palantir.logsafe.Arg<?> arg)
    Ensures the truth of an expression involving one or more parameters to the calling method.
    static void
    checkArgument(boolean expression, @Safe String message, com.palantir.logsafe.Arg<?>... args)
    Ensures the truth of an expression involving one or more parameters to the calling method.
    static void
    checkArgument(boolean expression, @Safe String message, com.palantir.logsafe.Arg<?> arg1, com.palantir.logsafe.Arg<?> arg2)
    Ensures the truth of an expression involving one or more parameters to the calling method.
    static void
    checkArgument(boolean expression, @Safe String message, com.palantir.logsafe.Arg<?> arg1, com.palantir.logsafe.Arg<?> arg2, com.palantir.logsafe.Arg<?> arg3)
    Ensures the truth of an expression involving one or more parameters to the calling method.
    static <T> T
    checkArgumentNotNull(T reference)
    Ensures that an Object reference passed as a parameter to the calling method is not null.
    static <T> T
    checkArgumentNotNull(T reference, @Safe String message)
    Ensures that an Object reference passed as a parameter to the calling method is not null.
    static <T> T
    checkArgumentNotNull(T reference, @Safe String message, com.palantir.logsafe.Arg<?> arg)
    Ensures that an Object reference passed as a parameter to the calling method is not null.
    static <T> T
    checkArgumentNotNull(T reference, @Safe String message, com.palantir.logsafe.Arg<?>... args)
    Ensures that an Object reference passed as a parameter to the calling method is not null.
    static <T> T
    checkArgumentNotNull(T reference, @Safe String message, com.palantir.logsafe.Arg<?> arg1, com.palantir.logsafe.Arg<?> arg2)
    Ensures that an Object reference passed as a parameter to the calling method is not null.
    static <T> T
    checkArgumentNotNull(T reference, @Safe String message, com.palantir.logsafe.Arg<?> arg1, com.palantir.logsafe.Arg<?> arg2, com.palantir.logsafe.Arg<?> arg3)
    Ensures that an Object reference passed as a parameter to the calling method is not null.
    static <T> T
    checkNotNull(T reference)
    Ensures that an Object reference passed as a parameter to the calling method is not null.
    static <T> T
    checkNotNull(T reference, @Safe String message)
    Ensures that an Object reference passed as a parameter to the calling method is not null.
    static <T> T
    checkNotNull(T reference, @Safe String message, com.palantir.logsafe.Arg<?> arg)
    Ensures that an Object reference passed as a parameter to the calling method is not null.
    static <T> T
    checkNotNull(T reference, @Safe String message, com.palantir.logsafe.Arg<?>... args)
    Ensures that an Object reference passed as a parameter to the calling method is not null.
    static <T> T
    checkNotNull(T reference, @Safe String message, com.palantir.logsafe.Arg<?> arg1, com.palantir.logsafe.Arg<?> arg2)
    Ensures that an Object reference passed as a parameter to the calling method is not null.
    static <T> T
    checkNotNull(T reference, @Safe String message, com.palantir.logsafe.Arg<?> arg1, com.palantir.logsafe.Arg<?> arg2, com.palantir.logsafe.Arg<?> arg3)
    Ensures that an Object reference passed as a parameter to the calling method is not null.
    static void
    checkState(boolean expression)
    Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.
    static void
    checkState(boolean expression, @Safe String message)
    Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.
    static void
    checkState(boolean expression, @Safe String message, com.palantir.logsafe.Arg<?> arg)
    Ensures the truth of an expression involving one or more parameters to the calling method.
    static void
    checkState(boolean expression, @Safe String message, com.palantir.logsafe.Arg<?>... args)
    Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.
    static void
    checkState(boolean expression, @Safe String message, com.palantir.logsafe.Arg<?> arg1, com.palantir.logsafe.Arg<?> arg2)
    Ensures the truth of an expression involving one or more parameters to the calling method.
    static void
    checkState(boolean expression, @Safe String message, com.palantir.logsafe.Arg<?> arg1, com.palantir.logsafe.Arg<?> arg2, com.palantir.logsafe.Arg<?> arg3)
    Ensures the truth of an expression involving one or more parameters to the calling method.

    Methods inherited from class Object

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

    • checkArgument

      @Contract("false -> fail") public static void checkArgument(boolean expression)
      Ensures the truth of an expression involving one or more parameters to the calling method.
      Parameters:
      expression - a boolean expression
      Throws:
      SafeIllegalArgumentException - if expression is false
    • checkArgument

      @Contract("false, _ -> fail") public static void checkArgument(boolean expression, @Safe @CompileTimeConstant @Safe String message)
      Ensures the truth of an expression involving one or more parameters to the calling method.
      Parameters:
      expression - a boolean expression
      message - the loggable exception message
      Throws:
      SafeIllegalArgumentException - if expression is false
    • checkArgument

      @Contract("false, _, _ -> fail") public static void checkArgument(boolean expression, @Safe @CompileTimeConstant @Safe String message, com.palantir.logsafe.Arg<?> arg)
      Ensures the truth of an expression involving one or more parameters to the calling method.

      See checkArgument(boolean, String, Arg...) for details.

    • checkArgument

      @Contract("false, _, _, _ -> fail") public static void checkArgument(boolean expression, @Safe @CompileTimeConstant @Safe String message, com.palantir.logsafe.Arg<?> arg1, com.palantir.logsafe.Arg<?> arg2)
      Ensures the truth of an expression involving one or more parameters to the calling method.

      See checkArgument(boolean, String, Arg...) for details.

    • checkArgument

      @Contract("false, _, _, _, _ -> fail") public static void checkArgument(boolean expression, @Safe @CompileTimeConstant @Safe String message, com.palantir.logsafe.Arg<?> arg1, com.palantir.logsafe.Arg<?> arg2, com.palantir.logsafe.Arg<?> arg3)
      Ensures the truth of an expression involving one or more parameters to the calling method.

      See checkArgument(boolean, String, Arg...) for details.

    • checkArgument

      @Contract("false, _, _ -> fail") public static void checkArgument(boolean expression, @Safe @CompileTimeConstant @Safe String message, com.palantir.logsafe.Arg<?>... args)
      Ensures the truth of an expression involving one or more parameters to the calling method.
      Parameters:
      expression - a boolean expression
      message - the loggable exception message
      args - the arguments to include in the SafeIllegalArgumentException
      Throws:
      SafeIllegalArgumentException - if expression is false
    • checkArgumentNotNull

      @Nonnull @CanIgnoreReturnValue @Contract("null -> fail; !null -> param1") public static <T> T checkArgumentNotNull(@Nullable T reference)
      Ensures that an Object reference passed as a parameter to the calling method is not null.
      Parameters:
      reference - an String reference
      Returns:
      the non-null reference that was validated
      Throws:
      SafeIllegalArgumentException - if reference is null
    • checkArgumentNotNull

      @Nonnull @CanIgnoreReturnValue @Contract("null, _ -> fail; !null, _ -> param1") public static <T> T checkArgumentNotNull(@Nullable T reference, @Safe @CompileTimeConstant @Safe String message)
      Ensures that an Object reference passed as a parameter to the calling method is not null.
      Parameters:
      reference - an String reference
      message - the loggable exception message
      Returns:
      the non-null reference that was validated
      Throws:
      SafeIllegalArgumentException - if reference is null
    • checkArgumentNotNull

      @Contract("null, _, _ -> fail; !null, _, _ -> param1") @Nonnull @CanIgnoreReturnValue public static <T> T checkArgumentNotNull(@Nullable T reference, @Safe @CompileTimeConstant @Safe String message, com.palantir.logsafe.Arg<?> arg)
      Ensures that an Object reference passed as a parameter to the calling method is not null.

      See checkArgumentNotNull(Object, String, Arg...) for details.

    • checkArgumentNotNull

      @Nonnull @CanIgnoreReturnValue @Contract("null, _, _, _ -> fail; !null, _, _, _ -> param1") public static <T> T checkArgumentNotNull(@Nullable T reference, @Safe @CompileTimeConstant @Safe String message, com.palantir.logsafe.Arg<?> arg1, com.palantir.logsafe.Arg<?> arg2)
      Ensures that an Object reference passed as a parameter to the calling method is not null.

      See checkArgumentNotNull(Object, String, Arg...) for details.

    • checkArgumentNotNull

      @Nonnull @CanIgnoreReturnValue @Contract("null, _, _, _, _ -> fail; !null, _, _, _, _ -> param1") public static <T> T checkArgumentNotNull(@Nullable T reference, @Safe @CompileTimeConstant @Safe String message, com.palantir.logsafe.Arg<?> arg1, com.palantir.logsafe.Arg<?> arg2, com.palantir.logsafe.Arg<?> arg3)
      Ensures that an Object reference passed as a parameter to the calling method is not null.

      See checkArgumentNotNull(Object, String, Arg...) for details.

    • checkArgumentNotNull

      @Nonnull @CanIgnoreReturnValue @Contract("null, _, _ -> fail; !null, _, _ -> param1") public static <T> T checkArgumentNotNull(@Nullable T reference, @Safe @CompileTimeConstant @Safe String message, com.palantir.logsafe.Arg<?>... args)
      Ensures that an Object reference passed as a parameter to the calling method is not null.
      Parameters:
      reference - an String reference
      message - the loggable exception message
      args - the arguments to include in the SafeIllegalArgumentException
      Returns:
      the non-null reference that was validated
      Throws:
      SafeIllegalArgumentException - if reference is null
    • checkState

      @Contract("false -> fail") public static void checkState(boolean expression)
      Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.
      Parameters:
      expression - a boolean expression
      Throws:
      SafeIllegalStateException - if expression is false
    • checkState

      @Contract("false, _ -> fail") public static void checkState(boolean expression, @Safe @CompileTimeConstant @Safe String message)
      Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.
      Parameters:
      expression - a boolean expression
      message - the loggable exception message
      Throws:
      SafeIllegalStateException - if expression is false
    • checkState

      @Contract("false, _, _ -> fail") public static void checkState(boolean expression, @Safe @CompileTimeConstant @Safe String message, com.palantir.logsafe.Arg<?> arg)
      Ensures the truth of an expression involving one or more parameters to the calling method.

      See checkState(boolean, String, Arg...) for details.

    • checkState

      @Contract("false, _, _, _ -> fail") public static void checkState(boolean expression, @Safe @CompileTimeConstant @Safe String message, com.palantir.logsafe.Arg<?> arg1, com.palantir.logsafe.Arg<?> arg2)
      Ensures the truth of an expression involving one or more parameters to the calling method.

      See checkState(boolean, String, Arg...) for details.

    • checkState

      @Contract("false, _, _, _, _ -> fail") public static void checkState(boolean expression, @Safe @CompileTimeConstant @Safe String message, com.palantir.logsafe.Arg<?> arg1, com.palantir.logsafe.Arg<?> arg2, com.palantir.logsafe.Arg<?> arg3)
      Ensures the truth of an expression involving one or more parameters to the calling method.

      See checkState(boolean, String, Arg...) for details.

    • checkState

      @Contract("false, _, _ -> fail") public static void checkState(boolean expression, @Safe @CompileTimeConstant @Safe String message, com.palantir.logsafe.Arg<?>... args)
      Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.
      Parameters:
      expression - a boolean expression
      message - the loggable exception message
      args - the arguments to include in the SafeIllegalStateException
      Throws:
      SafeIllegalStateException - if expression is false
    • checkNotNull

      @Contract("null -> fail; !null -> param1") @Nonnull @CanIgnoreReturnValue public static <T> T checkNotNull(@Nullable T reference)
      Ensures that an Object reference passed as a parameter to the calling method is not null.
      Parameters:
      reference - an String reference
      Returns:
      the non-null reference that was validated
      Throws:
      SafeNullPointerException - if reference is null
    • checkNotNull

      @Contract("null, _ -> fail; !null, _ -> param1") @Nonnull @CanIgnoreReturnValue public static <T> T checkNotNull(@Nullable T reference, @Safe @CompileTimeConstant @Safe String message)
      Ensures that an Object reference passed as a parameter to the calling method is not null.
      Parameters:
      reference - an String reference
      message - the loggable exception message
      Returns:
      the non-null reference that was validated
      Throws:
      SafeNullPointerException - if reference is null
    • checkNotNull

      @Contract("null, _, _ -> fail; !null, _, _ -> param1") @Nonnull @CanIgnoreReturnValue public static <T> T checkNotNull(@Nullable T reference, @Safe @CompileTimeConstant @Safe String message, com.palantir.logsafe.Arg<?> arg)
      Ensures that an Object reference passed as a parameter to the calling method is not null.

      See checkNotNull(Object, String, Arg...) for details.

    • checkNotNull

      @Contract("null, _, _, _ -> fail; !null, _, _, _ -> param1") @Nonnull @CanIgnoreReturnValue public static <T> T checkNotNull(@Nullable T reference, @Safe @CompileTimeConstant @Safe String message, com.palantir.logsafe.Arg<?> arg1, com.palantir.logsafe.Arg<?> arg2)
      Ensures that an Object reference passed as a parameter to the calling method is not null.

      See checkNotNull(Object, String, Arg...) for details.

    • checkNotNull

      @Contract("null, _, _, _, _ -> fail; !null, _, _, _, _ -> param1") @Nonnull @CanIgnoreReturnValue public static <T> T checkNotNull(@Nullable T reference, @Safe @CompileTimeConstant @Safe String message, com.palantir.logsafe.Arg<?> arg1, com.palantir.logsafe.Arg<?> arg2, com.palantir.logsafe.Arg<?> arg3)
      Ensures that an Object reference passed as a parameter to the calling method is not null.

      See checkNotNull(Object, String, Arg...) for details.

    • checkNotNull

      @Contract("null, _, _ -> fail; !null, _, _ -> param1") @Nonnull @CanIgnoreReturnValue public static <T> T checkNotNull(@Nullable T reference, @Safe @CompileTimeConstant @Safe String message, com.palantir.logsafe.Arg<?>... args)
      Ensures that an Object reference passed as a parameter to the calling method is not null.
      Parameters:
      reference - an String reference
      message - the loggable exception message
      args - the arguments to include in the SafeNullPointerException
      Returns:
      the non-null reference that was validated
      Throws:
      SafeNullPointerException - if reference is null