Klasse Assertions

java.lang.Object
org.opentcs.util.Assertions

public class Assertions extends Object
Utility methods for checking preconditions, postconditions etc..
  • Methodenübersicht

    Modifizierer und Typ
    Methode
    Beschreibung
    static void
    checkArgument(boolean expression, String errorMessage)
    Ensures the given expression is true.
    static void
    checkArgument(boolean expression, String messageTemplate, Object... messageArgs)
    Ensures the given expression is true.
    static int
    checkInRange(int value, int minimum, int maximum)
    Ensures that value is not smaller than minimum and not greater than maximum.
    static int
    checkInRange(int value, int minimum, int maximum, String valueName)
    Ensures that value is not smaller than minimum and not greater than maximum.
    static long
    checkInRange(long value, long minimum, long maximum)
    Ensures that value is not smaller than minimum and not greater than maximum.
    static long
    checkInRange(long value, long minimum, long maximum, String valueName)
    Ensures that value is not smaller than minimum and not greater than maximum.
    static void
    checkState(boolean expression, String errorMessage)
    Ensures the given expression is true.
    static void
    checkState(boolean expression, String messageTemplate, Object... messageArgs)
    Ensures the given expression is true.

    Von Klasse geerbte Methoden java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Methodendetails

    • checkArgument

      public static void checkArgument(boolean expression, String errorMessage) throws IllegalArgumentException
      Ensures the given expression is true.
      Parameter:
      expression - The expression to be checked.
      errorMessage - An optional error message.
      Löst aus:
      IllegalArgumentException - If the given expression is not true.
    • checkArgument

      public static void checkArgument(boolean expression, String messageTemplate, @Nullable Object... messageArgs) throws IllegalArgumentException
      Ensures the given expression is true.
      Parameter:
      expression - The expression to be checked.
      messageTemplate - A formatting template for the error message.
      messageArgs - The arguments to be formatted into the message template.
      Löst aus:
      IllegalArgumentException - If the given expression is not true.
    • checkState

      public static void checkState(boolean expression, String errorMessage) throws IllegalStateException
      Ensures the given expression is true.
      Parameter:
      expression - The expression to be checked.
      errorMessage - An optional error message.
      Löst aus:
      IllegalStateException - If the given expression is not true.
    • checkState

      public static void checkState(boolean expression, String messageTemplate, @Nullable Object... messageArgs) throws IllegalStateException
      Ensures the given expression is true.
      Parameter:
      expression - The expression to be checked.
      messageTemplate - A formatting template for the error message.
      messageArgs - The arguments to be formatted into the message template.
      Löst aus:
      IllegalStateException - If the given expression is not true.
    • checkInRange

      public static int checkInRange(int value, int minimum, int maximum) throws IllegalArgumentException
      Ensures that value is not smaller than minimum and not greater than maximum.
      Parameter:
      value - The value to be checked.
      minimum - The minimum value.
      maximum - The maximum value.
      Gibt zurück:
      The given value.
      Löst aus:
      IllegalArgumentException - If value is not within the given range.
    • checkInRange

      public static int checkInRange(int value, int minimum, int maximum, String valueName) throws IllegalArgumentException
      Ensures that value is not smaller than minimum and not greater than maximum.
      Parameter:
      value - The value to be checked.
      minimum - The minimum value.
      maximum - The maximum value.
      valueName - An optional name for the value to be used for the exception message.
      Gibt zurück:
      The given value.
      Löst aus:
      IllegalArgumentException - If value is not within the given range.
    • checkInRange

      public static long checkInRange(long value, long minimum, long maximum) throws IllegalArgumentException
      Ensures that value is not smaller than minimum and not greater than maximum.
      Parameter:
      value - The value to be checked.
      minimum - The minimum value.
      maximum - The maximum value.
      Gibt zurück:
      The given value.
      Löst aus:
      IllegalArgumentException - If value is not within the given range.
    • checkInRange

      public static long checkInRange(long value, long minimum, long maximum, String valueName) throws IllegalArgumentException
      Ensures that value is not smaller than minimum and not greater than maximum.
      Parameter:
      value - The value to be checked.
      minimum - The minimum value.
      maximum - The maximum value.
      valueName - An optional name for the value to be used for the exception message.
      Gibt zurück:
      The given value.
      Löst aus:
      IllegalArgumentException - If value is not within the given range.