Class Preconditions
java.lang.Object
com.palantir.logsafe.Preconditions
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckArgument(boolean expression) Ensures the truth of an expression involving one or more parameters to the calling method.static voidcheckArgument(boolean expression, @Safe String message) Ensures the truth of an expression involving one or more parameters to the calling method.static voidcheckArgument(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 voidcheckArgument(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 voidcheckArgument(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 voidcheckArgument(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> TcheckArgumentNotNull(T reference) Ensures that an Object reference passed as a parameter to the calling method is not null.static <T> TcheckArgumentNotNull(T reference, @Safe String message) Ensures that an Object reference passed as a parameter to the calling method is not null.static <T> TcheckArgumentNotNull(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> TcheckArgumentNotNull(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> TcheckArgumentNotNull(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> TcheckArgumentNotNull(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> TcheckNotNull(T reference) Ensures that an Object reference passed as a parameter to the calling method is not null.static <T> TcheckNotNull(T reference, @Safe String message) Ensures that an Object reference passed as a parameter to the calling method is not null.static <T> TcheckNotNull(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> TcheckNotNull(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> TcheckNotNull(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> TcheckNotNull(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 voidcheckState(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 voidcheckState(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 voidcheckState(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 voidcheckState(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 voidcheckState(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 voidcheckState(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.
-
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- ifexpressionis 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 expressionmessage- the loggable exception message- Throws:
SafeIllegalArgumentException- ifexpressionis 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 expressionmessage- the loggable exception messageargs- the arguments to include in theSafeIllegalArgumentException- Throws:
SafeIllegalArgumentException- ifexpressionis 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- ifreferenceis 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 referencemessage- the loggable exception message- Returns:
- the non-null reference that was validated
- Throws:
SafeIllegalArgumentException- ifreferenceis 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 referencemessage- the loggable exception messageargs- the arguments to include in theSafeIllegalArgumentException- Returns:
- the non-null reference that was validated
- Throws:
SafeIllegalArgumentException- ifreferenceis 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- ifexpressionis 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 expressionmessage- the loggable exception message- Throws:
SafeIllegalStateException- ifexpressionis 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 expressionmessage- the loggable exception messageargs- the arguments to include in theSafeIllegalStateException- Throws:
SafeIllegalStateException- ifexpressionis 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- ifreferenceis 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 referencemessage- the loggable exception message- Returns:
- the non-null reference that was validated
- Throws:
SafeNullPointerException- ifreferenceis 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 referencemessage- the loggable exception messageargs- the arguments to include in theSafeNullPointerException- Returns:
- the non-null reference that was validated
- Throws:
SafeNullPointerException- ifreferenceis null
-