Class Preconditions

java.lang.Object
org.bitcoinj.base.internal.Preconditions

public class Preconditions extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <X extends Throwable>
    void
    check(boolean expression, Supplier<? extends X> exceptionSupplier)
    Ensures the truth of an expression, throwing a custom exception if untrue.
    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, Supplier<String> messageSupplier)
    Ensures the truth of an expression involving one or more parameters to the calling method.
    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, Supplier<String> messageSupplier)
    Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.

    Methods inherited from class java.lang.Object

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

    • Preconditions

      public Preconditions()
  • Method Details

    • checkArgument

      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:
      IllegalArgumentException - if expression is false
    • checkArgument

      public static void checkArgument(boolean expression, Supplier<String> messageSupplier)
      Ensures the truth of an expression involving one or more parameters to the calling method.
      Parameters:
      expression - a boolean expression
      messageSupplier - supplier of the detail message to be used in the event that a IllegalArgumentException is thrown
      Throws:
      IllegalArgumentException - if expression is false
    • checkState

      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:
      IllegalStateException - if expression is false
    • checkState

      public static void checkState(boolean expression, Supplier<String> messageSupplier)
      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
      messageSupplier - supplier of the detail message to be used in the event that a IllegalStateException is thrown
      Throws:
      IllegalStateException - if expression is false
    • check

      public static <X extends Throwable> void check(boolean expression, Supplier<? extends X> exceptionSupplier) throws X
      Ensures the truth of an expression, throwing a custom exception if untrue.
      Parameters:
      expression - a boolean expression
      exceptionSupplier - supplier of the exception to be thrown
      Throws:
      X - if expression is false