org.eclipse.viatra.query.runtime.matchers.util

## Class Preconditions

- java.lang.Object
- - org.eclipse.viatra.query.runtime.matchers.util.Preconditions

-     public final class Preconditions
      extends java.lang.Object

  This class was motivated by the similar Preconditions class from Guava to provide simple precondition checking functionality. However, as starting with version 2.0 the runtime of VIATRA Query should not depend on Guava, the relevant functionality of the Preconditions checking functionality will be implemented here.
  Since:
    2.0

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and 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, java.lang.String errorMessage)` Ensures the truth of an expression involving one or more parameters to the calling method.
    `static void` | `checkArgument(boolean expression, java.lang.String errorMessageTemplate, java.lang.Object... errorMessageArgs)` Ensures the truth of an expression involving one or more parameters to the calling method.
    `static void` | `checkArgument(boolean expression, java.util.function.Supplier<java.lang.String> messageSupplier)` Ensures the truth of an expression involving one or more parameters to the calling method.
    `static void` | `checkElementIndex(int index, int size)` Ensures that an index is appropriate for a list or array of given size.
    `static void` | `checkElementIndex(int index, int size, java.lang.String errorMessageTemplate, java.lang.Object... errorMessageArgs)` Ensures that an index is appropriate for a list or array of given size.
    `static void` | `checkElementIndex(int index, int size, java.util.function.Supplier<java.lang.String> messageSupplier)` Ensures that an index is appropriate for a list or array of given size.
    `static void` | `checkState(boolean expression)` Ensures the truth of an expression involving one or more fields of a class.
    `static void` | `checkState(boolean expression, java.lang.String errorMessage)` Ensures the truth of an expression involving one or more fields of a class.
    `static void` | `checkState(boolean expression, java.lang.String errorMessageTemplate, java.lang.Object... errorMessageArgs)` Ensures the truth of an expression involving one or more fields of a class.
    `static void` | `checkState(boolean expression, java.util.function.Supplier<java.lang.String> messageSupplier)` Ensures the truth of an expression involving one or more fields of a class.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### 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:
        `java.lang.IllegalArgumentException` - if `expression` is false

    - #### checkArgument

          public static void checkArgument(boolean expression,
                                           java.lang.String errorMessage)

      Ensures the truth of an expression involving one or more parameters to the calling method.
      Parameters:
        `expression` - a boolean expression
        `errorMessage` - the exception message to use if the check fails
      Throws:
        `java.lang.IllegalArgumentException` - if `expression` is false

    - #### checkArgument

          public static void checkArgument(boolean expression,
                                           java.lang.String errorMessageTemplate,
                                           java.lang.Object... errorMessageArgs)

      Ensures the truth of an expression involving one or more parameters to the calling method.
      Parameters:
        `expression` - a boolean expression
        `errorMessageTemplate` - a template for the exception message should the check fail using the Java Formatter syntax; the same as used by `String.format(String, Object...)`.
        `errorMessageArgs` - the arguments to be substituted into the message template.
      Throws:
        `java.lang.IllegalArgumentException` - if `expression` is false
        `java.lang.NullPointerException` - if the check fails and either `errorMessageTemplate` or `errorMessageArgs` is null (don't let this happen)

    - #### checkArgument

          public static void checkArgument(boolean expression,
                                           java.util.function.Supplier<java.lang.String> messageSupplier)

      Ensures the truth of an expression involving one or more parameters to the calling method.
      Parameters:
        `expression` - a boolean expression
        `messageSupplier` - a supplier that is called to calculate the error message if necessary
      Throws:
        `java.lang.IllegalArgumentException` - if `expression` is false

    - #### checkState

          public static void checkState(boolean expression)

      Ensures the truth of an expression involving one or more fields of a class.
      Parameters:
        `expression` - a boolean expression
      Throws:
        `java.lang.IllegalStateException` - if `expression` is false

    - #### checkState

          public static void checkState(boolean expression,
                                        java.lang.String errorMessage)

      Ensures the truth of an expression involving one or more fields of a class.
      Parameters:
        `expression` - a boolean expression
        `errorMessage` - the exception message to use if the check fails
      Throws:
        `java.lang.IllegalStateException` - if `expression` is false

    - #### checkState

          public static void checkState(boolean expression,
                                        java.lang.String errorMessageTemplate,
                                        java.lang.Object... errorMessageArgs)

      Ensures the truth of an expression involving one or more fields of a class.
      Parameters:
        `expression` - a boolean expression
        `errorMessageTemplate` - a template for the exception message should the check fail using the Java Formatter syntax; the same as used by `String.format(String, Object...)`.
        `errorMessageArgs` - the arguments to be substituted into the message template.
      Throws:
        `java.lang.IllegalStateException` - if `expression` is false
        `java.lang.NullPointerException` - if the check fails and either `errorMessageTemplate` or `errorMessageArgs` is null (don't let this happen)

    - #### checkState

          public static void checkState(boolean expression,
                                        java.util.function.Supplier<java.lang.String> messageSupplier)

      Ensures the truth of an expression involving one or more fields of a class.
      Parameters:
        `expression` - a boolean expression
        `messageSupplier` - a supplier that is called to calculate the error message if necessary
      Throws:
        `java.lang.IllegalStateException` - if `expression` is false

    - #### checkElementIndex

          public static void checkElementIndex(int index,
                                               int size)

      Ensures that an index is appropriate for a list or array of given size.
      Parameters:
        `index` -
        `size` -
      Throws:
        `java.lang.IndexOutOfBoundsException` - if index is negative or is greater or equal to size

    - #### checkElementIndex

          public static void checkElementIndex(int index,
                                               int size,
                                               java.lang.String errorMessageTemplate,
                                               java.lang.Object... errorMessageArgs)

      Ensures that an index is appropriate for a list or array of given size.
      Parameters:
        `index` -
        `size` -
        `errorMessageTemplate` - a template for the exception message should the check fail using the Java Formatter syntax; the same as used by `String.format(String, Object...)`.
        `errorMessageArgs` - the arguments to be substituted into the message template.
      Throws:
        `java.lang.IndexOutOfBoundsException` - if index is negative or is greater or equal to size

    - #### checkElementIndex

          public static void checkElementIndex(int index,
                                               int size,
                                               java.util.function.Supplier<java.lang.String> messageSupplier)

      Ensures that an index is appropriate for a list or array of given size.
      Parameters:
        `index` -
        `size` -
        `messageSupplier` - a supplier that is called to calculate the error message if necessary
      Throws:
        `java.lang.IndexOutOfBoundsException` - if index is negative or is greater or equal to size