Class Requires

java.lang.Object
io.jenetics.internal.util.Requires

public final class Requires extends Object
Some helper methods for creating hash codes and comparing values.
Since:
1.0
Version:
5.2
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    nonNegative(double value)
    Check if the specified value is not negative.
    static double
    nonNegative(double value, String message)
    Check if the specified value is not negative.
    static int
    nonNegative(int length)
    Check if the given integer is negative.
    static double
    positive(double value)
     
    static int
    positive(int value)
    Require the given value to be positive (> 0).
    static long
    positive(long value)
     
    static double
    probability(double p)
    Check if the given double value is within the closed range [0, 1].

    Methods inherited from class java.lang.Object

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

    • nonNegative

      public static double nonNegative(double value, String message)
      Check if the specified value is not negative.
      Parameters:
      value - the value to check.
      message - the exception message.
      Returns:
      the given value.
      Throws:
      IllegalArgumentException - if value < 0.
    • nonNegative

      public static double nonNegative(double value)
      Check if the specified value is not negative.
      Parameters:
      value - the value to check.
      Returns:
      the given value.
      Throws:
      IllegalArgumentException - if value < 0.
    • nonNegative

      public static int nonNegative(int length)
      Check if the given integer is negative.
      Parameters:
      length - the value to check.
      Returns:
      the length input
      Throws:
      NegativeArraySizeException - if the given length is smaller than zero.
    • positive

      public static int positive(int value)
      Require the given value to be positive (> 0).
      Parameters:
      value - the value to check
      Returns:
      the given value
      Throws:
      IllegalArgumentException - if the given value is smaller than or equal zero.
    • positive

      public static long positive(long value)
    • positive

      public static double positive(double value)
    • probability

      public static double probability(double p)
      Check if the given double value is within the closed range [0, 1].
      Parameters:
      p - the probability to check.
      Returns:
      p if it is a valid probability.
      Throws:
      IllegalArgumentException - if p is not a valid probability.