Class Checks

java.lang.Object
org.jparsec.internal.util.Checks

public final class Checks extends Object
Common facilities to check precondition, postcondition and invariants.
  • Constructor Details

    • Checks

      public Checks()
  • Method Details

    • checkNotNull

      public static <T> T checkNotNull(T value) throws NullPointerException
      Checks that value cannot be null.
      Throws:
      NullPointerException
    • checkArgument

      public static void checkArgument(boolean condition, String message) throws IllegalArgumentException
      Checks that an argument satisfies requirement.
      Parameters:
      condition - the condition that has to be true
      message - the error message if condition is false
      args - the arguments to the error message
      Throws:
      IllegalArgumentException - if condition is false
    • checkArgument

      public static void checkArgument(boolean condition, String message, Object... args) throws IllegalArgumentException
      Checks that an argument satisfies requirement.
      Parameters:
      condition - the condition that has to be true
      message - the error message if condition is false
      args - the arguments to the error message
      Throws:
      IllegalArgumentException - if condition is false
    • checkState

      public static void checkState(boolean condition, String message) throws IllegalStateException
      Checks a certain state.
      Parameters:
      condition - the condition of the state that has to be true
      message - the error message if condition is false
      args - the arguments to the error message
      Throws:
      IllegalStateException - if condition is false
    • checkState

      public static void checkState(boolean condition, String message, Object... args) throws IllegalStateException
      Checks a certain state.
      Parameters:
      condition - the condition of the state that has to be true
      message - the error message if condition is false
      args - the arguments to the error message
      Throws:
      IllegalStateException - if condition is false
    • checkNotNullState

      public static void checkNotNullState(Object object, String message)
      Checks that object is not null.
      Parameters:
      object - the object that cannot be null
      message - the error message if condition is false
      args - the arguments to the error message
      Throws:
      IllegalStateException - if object is null
    • checkNotNullState

      public static void checkNotNullState(Object object, String message, Object... args)
      Checks that object is not null.
      Parameters:
      object - the object that cannot be null
      message - the error message if condition is false
      args - the arguments to the error message
      Throws:
      IllegalStateException - if object is null
    • checkMinMax

      public static void checkMinMax(int min, int max)
      Checks that neither min or max is negative and min &lt;= max.
    • checkMin

      public static int checkMin(int min)
      Checks that min isn't negative.
    • checkMax

      public static int checkMax(int max)
      Checks that max isn't negative.
    • checkNonNegative

      public static int checkNonNegative(int n, String message)
      Checks that n isn't negative. Or throws an IllegalArgumentException with message.