Class Validate


  • public class Validate
    extends java.lang.Object
    Utility class to validate input parameters and the current state. In order to distinguish null parameters and a parameters containing null a NullPointerException and IllegalArgumentException is thrown respectively.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void fail()
      Throws a IllegalStateException.
      static void fail​(java.lang.String message, java.lang.Object... args)
      Throws a IllegalStateException.
      static java.lang.String hasPattern​(java.lang.String s, java.lang.String pattern)
      Validates that s matches pattern using String.matches(String).
      static java.lang.String hasPattern​(java.lang.String s, java.lang.String pattern, java.lang.String message, java.lang.Object... args)
      Validates that s matches pattern using String.matches(String).
      static <T extends java.lang.Comparable<T>>
      T
      hasRange​(T t, T from, T to)
      Validates that from <= t <= to.
      static <T extends java.lang.Comparable<T>>
      T
      hasRange​(T t, T from, T to, java.lang.String message, java.lang.Object... args)
      Validates that from <= t <= to.
      static VCSFile isEqualTo​(VCSFile file, VCSFile compare)
      Validates that file is equal to compare.
      static VCSFile isEqualTo​(VCSFile file, VCSFile compare, java.lang.String message, java.lang.Object... args)
      Validates that file is equal to compare.
      static <T extends java.lang.Comparable<T>>
      T
      isEqualTo​(T t, T compare)
      Validates that t.compareTo(compare) == 0.
      static <T extends java.lang.Comparable<T>>
      T
      isEqualTo​(T t, T compare, java.lang.String message, java.lang.Object... args)
      Validates that t.compareTo(compare) == 0.
      static void isFalse​(boolean b)
      Validates that b is false.
      static void isFalse​(boolean b, java.lang.String message, java.lang.Object... args)
      Validates that b is false.
      static <T extends java.lang.Comparable<T>>
      T
      isGreaterThan​(T t, T compare)
      Validates that t > compare.
      static <T extends java.lang.Comparable<T>>
      T
      isGreaterThan​(T t, T compare, java.lang.String message, java.lang.Object... args)
      Validates that t > compare.
      static <T extends java.lang.Comparable<T>>
      T
      isGreaterThanOrEquals​(T t, T compare)
      Validates that t >= compare.
      static <T extends java.lang.Comparable<T>>
      T
      isGreaterThanOrEquals​(T t, T compare, java.lang.String message, java.lang.Object... args)
      Validates that t >= compare.
      static <T extends java.lang.Comparable<T>>
      T
      isLessThan​(T t, T compare)
      Validates that t.compareTo(compare) < 0.
      static <T extends java.lang.Comparable<T>>
      T
      isLessThan​(T t, T compare, java.lang.String message, java.lang.Object... args)
      Validates that t.compareTo(compare) < 0.
      static <T extends java.lang.Comparable<T>>
      T
      isLessThanOrEquals​(T t, T compare)
      Validates that t.compareTo(compare) <= 0.
      static <T extends java.lang.Comparable<T>>
      T
      isLessThanOrEquals​(T t, T compare, java.lang.String message, java.lang.String args)
      Validates that t.compareTo(compare) <= 0.
      static double isNegative​(double d)
      Validates that d is negative.
      static double isNegative​(double d, java.lang.String message, java.lang.Object... args)
      Validates that d is negative.
      static int isNegative​(int i)
      Validates that i is negative.
      static int isNegative​(int i, java.lang.String message, java.lang.Object... args)
      Validates that i is negative.
      static double isPositive​(double d)
      Validates that d is positive (> 0).
      static double isPositive​(double d, java.lang.String message, java.lang.Object... args)
      Validates that d is positive (> 0).
      static int isPositive​(int i)
      Validates that i is positive (> 0).
      static int isPositive​(int i, java.lang.String message, java.lang.Object... args)
      Validates that i is positive (> 0).
      static void isTrue​(boolean b)
      Validates that b is true.
      static void isTrue​(boolean b, java.lang.String message, java.lang.Object... args)
      Validates that b is true.
      static <T extends java.util.Collection<?>>
      T
      noNullElements​(T t)
      Validates that t is not null and does not contain null values.
      static <T extends java.util.Collection<?>>
      T
      noNullElements​(T t, java.lang.String message, java.lang.Object... args)
      Validates that t is not null and does not contain null values.
      static java.lang.String notBlank​(java.lang.String s)
      Validates that s is not null and contains at least one non-space character.
      static java.lang.String notBlank​(java.lang.String s, java.lang.String message, java.lang.Object... args)
      Validates that s is not null and contains at least one non-space character.
      static java.lang.String notEmpty​(java.lang.String s)
      Validates that s is not null and not empty.
      static java.lang.String notEmpty​(java.lang.String s, java.lang.String message, java.lang.Object... args)
      Validates that s is not null and not empty.
      static <T extends java.util.Collection<?>>
      T
      notEmpty​(T t)
      Validates that t is not null, does not contain null values, and is not empty.
      static <T extends java.util.Collection<?>>
      T
      notEmpty​(T t, java.lang.String message, java.lang.Object... args)
      Validates that t is not null, does not contain null values, and is not empty.
      static <T extends java.lang.Comparable<T>>
      T
      notEquals​(T t, T compare)
      Validates that t.compareTo(compare) != 0.
      static <T extends java.lang.Comparable<T>>
      T
      notEquals​(T t, T compare, java.lang.String message, java.lang.Object... args)
      Validates that t.compareTo(compare) != 0.
      static double notNegative​(double d)
      Validates that d is not negative.
      static double notNegative​(double d, java.lang.String message, java.lang.Object... args)
      Validates that d is not negative.
      static int notNegative​(int i)
      Validates that i is not negative.
      static int notNegative​(int i, java.lang.String message, java.lang.Object... args)
      Validates that i is not negative.
      static <T> T notNull​(T t)
      Validates that t is not null.
      static <T> T notNull​(T t, java.lang.String message, java.lang.Object... args)
      Validates that t is not null.
      static void validateState​(boolean expression)
      Validates that expression is true.
      static void validateState​(boolean expression, java.lang.String message, java.lang.Object... args)
      Validates that expression is true.
      • Methods inherited from class java.lang.Object

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

      • notNull

        public static <T> T notNull​(T t)
                             throws java.lang.NullPointerException
        Validates that t is not null.
        Type Parameters:
        T - The type of t.
        Parameters:
        t - The value to validate.
        Returns:
        t, never null.
        Throws:
        java.lang.NullPointerException - If t is null.
      • notNull

        public static <T> T notNull​(T t,
                                    java.lang.String message,
                                    java.lang.Object... args)
                             throws java.lang.NullPointerException
        Validates that t is not null.
        Type Parameters:
        T - The type of t.
        Parameters:
        t - The value to validate.
        message - The message of the thrown exception.
        args - The arguments to pass to String.format(String, Object...).
        Returns:
        t, never null.
        Throws:
        java.lang.NullPointerException - If t is null.
      • noNullElements

        public static <T extends java.util.Collection<?>> T noNullElements​(T t)
                                                                    throws java.lang.NullPointerException,
                                                                           java.lang.IllegalArgumentException
        Validates that t is not null and does not contain null values.
        Type Parameters:
        T - The type of t.
        Parameters:
        t - The value to validate.
        Returns:
        t, never null.
        Throws:
        java.lang.NullPointerException - If t is null.
        java.lang.IllegalArgumentException - If t contains null.
      • noNullElements

        public static <T extends java.util.Collection<?>> T noNullElements​(T t,
                                                                           java.lang.String message,
                                                                           java.lang.Object... args)
                                                                    throws java.lang.NullPointerException,
                                                                           java.lang.IllegalArgumentException
        Validates that t is not null and does not contain null values.
        Type Parameters:
        T - The type of t.
        Parameters:
        t - The value to validate.
        message - The message of the thrown exception.
        args - The arguments to pass to String.format(String, Object...).
        Returns:
        t, never null.
        Throws:
        java.lang.NullPointerException - If t is null.
        java.lang.IllegalArgumentException - If t contains null.
      • noNullElements

        public static <T extends java.util.Map<?,​?>> T noNullElements​(T t)
        Validates that t is not null and does not contain null keys and values.
        Type Parameters:
        T - The type of t.
        Parameters:
        t - The value to validate.
        Returns:
        t, never null.
        Throws:
        java.lang.NullPointerException - If t is null.
        java.lang.IllegalArgumentException - If t contains null keys or values.
      • noNullElements

        public static <T extends java.util.Map<?,​?>> T noNullElements​(T t,
                                                                            java.lang.String message,
                                                                            java.lang.Object... args)
        Validates that t is not null and does not contain null keys and values.
        Type Parameters:
        T - The type of t.
        Parameters:
        t - The value to validate.
        message - The message of the thrown exception.
        args - The arguments to pass to String.format(String, Object...).
        Returns:
        t, never null.
        Throws:
        java.lang.NullPointerException - If t is null.
        java.lang.IllegalArgumentException - If t contains null keys or values.
      • notEmpty

        public static <T extends java.util.Collection<?>> T notEmpty​(T t)
                                                              throws java.lang.NullPointerException,
                                                                     java.lang.IllegalArgumentException
        Validates that t is not null, does not contain null values, and is not empty.
        Type Parameters:
        T - The type of t.
        Parameters:
        t - The value to validate.
        Returns:
        t, never null.
        Throws:
        java.lang.NullPointerException - If t is null.
        java.lang.IllegalArgumentException - If t contains null or is empty.
      • notEmpty

        public static <T extends java.util.Collection<?>> T notEmpty​(T t,
                                                                     java.lang.String message,
                                                                     java.lang.Object... args)
                                                              throws java.lang.NullPointerException,
                                                                     java.lang.IllegalArgumentException
        Validates that t is not null, does not contain null values, and is not empty.
        Type Parameters:
        T - The type of t.
        Parameters:
        t - The value to validate.
        message - The message of the thrown exception.
        args - The arguments to pass to String.format(String, Object...).
        Returns:
        t, never null.
        Throws:
        java.lang.NullPointerException - If t is null.
        java.lang.IllegalArgumentException - If t contains null or is empty.
      • notEmpty

        public static java.lang.String notEmpty​(java.lang.String s)
                                         throws java.lang.NullPointerException,
                                                java.lang.IllegalArgumentException
        Validates that s is not null and not empty.
        Parameters:
        s - The string to validate.
        Returns:
        s, never null.
        Throws:
        java.lang.NullPointerException - If s is null.
        java.lang.IllegalArgumentException - If s is empty.
      • notEmpty

        public static java.lang.String notEmpty​(java.lang.String s,
                                                java.lang.String message,
                                                java.lang.Object... args)
                                         throws java.lang.NullPointerException,
                                                java.lang.IllegalArgumentException
        Validates that s is not null and not empty.
        Parameters:
        s - The string to validate.
        message - The message of the thrown exception.
        args - The arguments to pass to String.format(String, Object...).
        Returns:
        s, never null.
        Throws:
        java.lang.NullPointerException - If s is null.
        java.lang.IllegalArgumentException - If s is empty.
      • notBlank

        public static java.lang.String notBlank​(java.lang.String s)
                                         throws java.lang.NullPointerException,
                                                java.lang.IllegalArgumentException
        Validates that s is not null and contains at least one non-space character.
        Parameters:
        s - The string to validate.
        Returns:
        s, never a value that is null or consists of spaces only.
        Throws:
        java.lang.NullPointerException - If s is null.
        java.lang.IllegalArgumentException - If s consists of spaces only.
      • notBlank

        public static java.lang.String notBlank​(java.lang.String s,
                                                java.lang.String message,
                                                java.lang.Object... args)
                                         throws java.lang.NullPointerException,
                                                java.lang.IllegalArgumentException
        Validates that s is not null and contains at least one non-space character.
        Parameters:
        s - The string to validate.
        message - The message of the thrown exception.
        args - The arguments to pass to String.format(String, Object...).
        Returns:
        s, never a value that is null or consists of spaces only.
        Throws:
        java.lang.NullPointerException - If s is null.
        java.lang.IllegalArgumentException - If s consists of spaces only.
      • hasPattern

        public static java.lang.String hasPattern​(java.lang.String s,
                                                  java.lang.String pattern)
                                           throws java.lang.NullPointerException,
                                                  java.lang.IllegalArgumentException
        Validates that s matches pattern using String.matches(String).
        Parameters:
        s - The string to validate.
        pattern - The pattern to match.
        Returns:
        s, never a value that doesn't match pattern.
        Throws:
        java.lang.NullPointerException - If any of the given arguments is null.
        java.lang.IllegalArgumentException - If s does not match pattern.
      • hasPattern

        public static java.lang.String hasPattern​(java.lang.String s,
                                                  java.lang.String pattern,
                                                  java.lang.String message,
                                                  java.lang.Object... args)
                                           throws java.lang.NullPointerException,
                                                  java.lang.IllegalArgumentException
        Validates that s matches pattern using String.matches(String).
        Parameters:
        s - The string to validate.
        pattern - The pattern to match.
        message - The message of the thrown exception.
        args - The arguments to pass to String.format(String, Object...).
        Returns:
        s, never a value that doesn't match pattern.
        Throws:
        java.lang.NullPointerException - If any of the given arguments is null.
        java.lang.IllegalArgumentException - If s does not match pattern.
      • notNegative

        public static int notNegative​(int i)
                               throws java.lang.IllegalArgumentException
        Validates that i is not negative.
        Parameters:
        i - The integer to validate.
        Returns:
        i, never a negative value.
        Throws:
        java.lang.IllegalArgumentException - If i < 0.
      • notNegative

        public static int notNegative​(int i,
                                      java.lang.String message,
                                      java.lang.Object... args)
                               throws java.lang.IllegalArgumentException
        Validates that i is not negative.
        Parameters:
        i - The integer to validate.
        message - The message of the thrown exception.
        args - The arguments to pass to String.format(String, Object...).
        Returns:
        i, never a negative value.
        Throws:
        java.lang.IllegalArgumentException - If i < 0.
      • notNegative

        public static double notNegative​(double d)
                                  throws java.lang.IllegalArgumentException
        Validates that d is not negative.
        Parameters:
        d - The double to validate.
        Returns:
        d, never a negative value.
        Throws:
        java.lang.IllegalArgumentException - If d < 0.
      • notNegative

        public static double notNegative​(double d,
                                         java.lang.String message,
                                         java.lang.Object... args)
                                  throws java.lang.IllegalArgumentException
        Validates that d is not negative.
        Parameters:
        d - The double to validate.
        message - The message of the thrown exception.
        args - The arguments to pass to String.format(String, Object...).
        Returns:
        d, never a negative value.
        Throws:
        java.lang.IllegalArgumentException - If d < 0.
      • isNegative

        public static int isNegative​(int i)
                              throws java.lang.IllegalArgumentException
        Validates that i is negative.
        Parameters:
        i - The integer to validate.
        Returns:
        i, never a value >= 0.
        Throws:
        java.lang.IllegalArgumentException - If i >= 0.
      • isNegative

        public static int isNegative​(int i,
                                     java.lang.String message,
                                     java.lang.Object... args)
                              throws java.lang.IllegalArgumentException
        Validates that i is negative.
        Parameters:
        i - The integer to validate.
        message - The message of the thrown exception.
        args - The arguments to pass to String.format(String, Object...).
        Returns:
        i, never a value >= 0.
        Throws:
        java.lang.IllegalArgumentException - If i >= 0.
      • isNegative

        public static double isNegative​(double d)
                                 throws java.lang.IllegalArgumentException
        Validates that d is negative.
        Parameters:
        d - The double to validate.
        Returns:
        d, never a value >= 0.
        Throws:
        java.lang.IllegalArgumentException - If d >= 0.
      • isNegative

        public static double isNegative​(double d,
                                        java.lang.String message,
                                        java.lang.Object... args)
                                 throws java.lang.IllegalArgumentException
        Validates that d is negative.
        Parameters:
        d - The double to validate.
        message - The message of the thrown exception.
        args - The arguments to pass to String.format(String, Object...).
        Returns:
        d, never a value >= 0.
        Throws:
        java.lang.IllegalArgumentException - If d >= 0.
      • isPositive

        public static int isPositive​(int i)
                              throws java.lang.IllegalArgumentException
        Validates that i is positive (> 0).
        Parameters:
        i - The integer to validate.
        Returns:
        i, never a value <= 0.
        Throws:
        java.lang.IllegalArgumentException - If i <= 0.
      • isPositive

        public static int isPositive​(int i,
                                     java.lang.String message,
                                     java.lang.Object... args)
                              throws java.lang.IllegalArgumentException
        Validates that i is positive (> 0).
        Parameters:
        i - The integer to validate.
        message - The message of the thrown exception.
        args - The arguments to pass to String.format(String, Object...).
        Returns:
        i, never a value <= 0.
        Throws:
        java.lang.IllegalArgumentException - If i <= 0.
      • isPositive

        public static double isPositive​(double d)
                                 throws java.lang.IllegalArgumentException
        Validates that d is positive (> 0).
        Parameters:
        d - The double to validate.
        Returns:
        d, never a value <= 0.
        Throws:
        java.lang.IllegalArgumentException - If d <= 0.
      • isPositive

        public static double isPositive​(double d,
                                        java.lang.String message,
                                        java.lang.Object... args)
                                 throws java.lang.IllegalArgumentException
        Validates that d is positive (> 0).
        Parameters:
        d - The double to validate.
        message - The message of the thrown exception.
        args - The arguments to pass to String.format(String, Object...).
        Returns:
        d, never a value <= 0.
        Throws:
        java.lang.IllegalArgumentException - If d <= 0.
      • hasRange

        public static <T extends java.lang.Comparable<T>> T hasRange​(T t,
                                                                     T from,
                                                                     T to)
                                                              throws java.lang.NullPointerException,
                                                                     java.lang.IllegalArgumentException
        Validates that from <= t <= to.
        Type Parameters:
        T - The type of t, from, and to.
        Parameters:
        t - The value to validate.
        from - The from value.
        to - The to value.
        Returns:
        t, never a value < from or > to.
        Throws:
        java.lang.NullPointerException - If any of the given arguments is null.
        java.lang.IllegalArgumentException - If t < from or t > to.
      • hasRange

        public static <T extends java.lang.Comparable<T>> T hasRange​(T t,
                                                                     T from,
                                                                     T to,
                                                                     java.lang.String message,
                                                                     java.lang.Object... args)
                                                              throws java.lang.NullPointerException,
                                                                     java.lang.IllegalArgumentException
        Validates that from <= t <= to.
        Type Parameters:
        T - The type of t, from, and to.
        Parameters:
        t - The value to validate.
        from - The from value.
        to - The to value.
        message - The message of the thrown exception.
        args - The arguments to pass to String.format(String, Object...).
        Returns:
        t, never a value < from or > to.
        Throws:
        java.lang.NullPointerException - If any of the given arguments is null.
        java.lang.IllegalArgumentException - If t < from or t > to.
      • isGreaterThan

        public static <T extends java.lang.Comparable<T>> T isGreaterThan​(T t,
                                                                          T compare)
                                                                   throws java.lang.NullPointerException,
                                                                          java.lang.IllegalArgumentException
        Validates that t > compare.
        Type Parameters:
        T - The type of t and compare.
        Parameters:
        t - The value to validate.
        compare - The value to compare to t.
        Returns:
        t, never a value <= compare
        Throws:
        java.lang.NullPointerException - If any of the given arguments is null.
        java.lang.IllegalArgumentException - If t <= compare.
      • isGreaterThan

        public static <T extends java.lang.Comparable<T>> T isGreaterThan​(T t,
                                                                          T compare,
                                                                          java.lang.String message,
                                                                          java.lang.Object... args)
                                                                   throws java.lang.NullPointerException,
                                                                          java.lang.IllegalArgumentException
        Validates that t > compare.
        Type Parameters:
        T - The type of t and compare.
        Parameters:
        t - The value to validate.
        compare - The value to compare to t.
        message - The message of the thrown exception.
        args - The arguments to pass to String.format(String, Object...).
        Returns:
        t, never a value <= compare
        Throws:
        java.lang.NullPointerException - If any of the given arguments is null.
        java.lang.IllegalArgumentException - If t <= compare.
      • isGreaterThanOrEquals

        public static <T extends java.lang.Comparable<T>> T isGreaterThanOrEquals​(T t,
                                                                                  T compare)
                                                                           throws java.lang.NullPointerException,
                                                                                  java.lang.IllegalArgumentException
        Validates that t >= compare.
        Type Parameters:
        T - The type of t and compare.
        Parameters:
        t - The value to validate.
        compare - The value to compare to t.
        Returns:
        t, never a value < compare.
        Throws:
        java.lang.NullPointerException - If any of the given arguments is null.
        java.lang.IllegalArgumentException - If t < compare.
      • isGreaterThanOrEquals

        public static <T extends java.lang.Comparable<T>> T isGreaterThanOrEquals​(T t,
                                                                                  T compare,
                                                                                  java.lang.String message,
                                                                                  java.lang.Object... args)
                                                                           throws java.lang.NullPointerException,
                                                                                  java.lang.IllegalArgumentException
        Validates that t >= compare.
        Type Parameters:
        T - The type of t and compare.
        Parameters:
        t - The value to validate.
        compare - The value to compare to t.
        message - The message of the thrown exception.
        args - The arguments to pass to String.format(String, Object...).
        Returns:
        t, never a value < compare.
        Throws:
        java.lang.NullPointerException - If any of the given arguments is null.
        java.lang.IllegalArgumentException - If t < compare.
      • isEqualTo

        public static <T extends java.lang.Comparable<T>> T isEqualTo​(T t,
                                                                      T compare)
                                                               throws java.lang.NullPointerException,
                                                                      java.lang.IllegalArgumentException
        Validates that t.compareTo(compare) == 0.
        Type Parameters:
        T - The type of t and compare.
        Parameters:
        t - The value to validate.
        compare - The value to compare to t.
        Returns:
        t, never a value != compare.
        Throws:
        java.lang.NullPointerException - If any of the given arguments is null.
        java.lang.IllegalArgumentException - If t.compareTo(compare) != 0.
      • isEqualTo

        public static <T extends java.lang.Comparable<T>> T isEqualTo​(T t,
                                                                      T compare,
                                                                      java.lang.String message,
                                                                      java.lang.Object... args)
                                                               throws java.lang.NullPointerException,
                                                                      java.lang.IllegalArgumentException
        Validates that t.compareTo(compare) == 0.
        Type Parameters:
        T - The type of t and compare.
        Parameters:
        t - The value to validate.
        compare - The value to compare to t.
        message - The message of the thrown exception.
        args - The arguments to pass to String.format(String, Object...).
        Returns:
        t, never a value != compare.
        Throws:
        java.lang.NullPointerException - If any of the given arguments is null.
        java.lang.IllegalArgumentException - If t.compareTo(compare) != 0.
      • notEquals

        public static <T extends java.lang.Comparable<T>> T notEquals​(T t,
                                                                      T compare)
                                                               throws java.lang.NullPointerException,
                                                                      java.lang.IllegalArgumentException
        Validates that t.compareTo(compare) != 0.
        Type Parameters:
        T - The type of t and compare.
        Parameters:
        t - The value to validate.
        compare - The value to compare to t.
        Returns:
        t, never a value == compare.
        Throws:
        java.lang.NullPointerException - If any of the given arguments is null.
        java.lang.IllegalArgumentException - If t.compareTo(compare) == 0.
      • notEquals

        public static <T extends java.lang.Comparable<T>> T notEquals​(T t,
                                                                      T compare,
                                                                      java.lang.String message,
                                                                      java.lang.Object... args)
                                                               throws java.lang.NullPointerException,
                                                                      java.lang.IllegalArgumentException
        Validates that t.compareTo(compare) != 0.
        Type Parameters:
        T - The type of t and compare.
        Parameters:
        t - The value to validate.
        compare - The value to compare to t.
        message - The message of the thrown exception.
        args - The arguments to pass to String.format(String, Object...).
        Returns:
        t, never a value == compare.
        Throws:
        java.lang.NullPointerException - If any of the given arguments is null.
        java.lang.IllegalArgumentException - If t.compareTo(compare) == 0.
      • isLessThanOrEquals

        public static <T extends java.lang.Comparable<T>> T isLessThanOrEquals​(T t,
                                                                               T compare)
                                                                        throws java.lang.NullPointerException,
                                                                               java.lang.IllegalArgumentException
        Validates that t.compareTo(compare) <= 0.
        Type Parameters:
        T - The type of t and compare.
        Parameters:
        t - The value to validate.
        compare - The value to compare to t.
        Returns:
        t, never a value > compare.
        Throws:
        java.lang.NullPointerException - If any of the given arguments is null.
        java.lang.IllegalArgumentException - If t.compareTo(compare) > 0.
      • isLessThanOrEquals

        public static <T extends java.lang.Comparable<T>> T isLessThanOrEquals​(T t,
                                                                               T compare,
                                                                               java.lang.String message,
                                                                               java.lang.String args)
                                                                        throws java.lang.NullPointerException,
                                                                               java.lang.IllegalArgumentException
        Validates that t.compareTo(compare) <= 0.
        Type Parameters:
        T - The type of t and compare.
        Parameters:
        t - The value to validate.
        compare - The value to compare to t.
        message - The message of the thrown exception.
        args - The arguments to pass to String.format(String, Object...).
        Returns:
        t, never a value > compare.
        Throws:
        java.lang.NullPointerException - If any of the given arguments is null.
        java.lang.IllegalArgumentException - If t.compareTo(compare) > 0.
      • isLessThan

        public static <T extends java.lang.Comparable<T>> T isLessThan​(T t,
                                                                       T compare)
                                                                throws java.lang.NullPointerException,
                                                                       java.lang.IllegalArgumentException
        Validates that t.compareTo(compare) < 0.
        Type Parameters:
        T - The type of t and compare.
        Parameters:
        t - The value to validate.
        compare - The value to compare to t.
        Returns:
        t, never a value >= compare.
        Throws:
        java.lang.NullPointerException - If any of the given arguments is null.
        java.lang.IllegalArgumentException - If t.compareTo(compare) >= 0.
      • isLessThan

        public static <T extends java.lang.Comparable<T>> T isLessThan​(T t,
                                                                       T compare,
                                                                       java.lang.String message,
                                                                       java.lang.Object... args)
                                                                throws java.lang.NullPointerException,
                                                                       java.lang.IllegalArgumentException
        Validates that t.compareTo(compare) < 0.
        Type Parameters:
        T - The type of t and compare.
        Parameters:
        t - The value to validate.
        compare - The value to compare to t.
        message - The message of the thrown exception.
        args - The arguments to pass to String.format(String, Object...).
        Returns:
        t, never a value >= compare.
        Throws:
        java.lang.NullPointerException - If any of the given arguments is null.
        java.lang.IllegalArgumentException - If t.compareTo(compare) >= 0.
      • isTrue

        public static void isTrue​(boolean b)
                           throws java.lang.IllegalArgumentException
        Validates that b is true.
        Parameters:
        b - The boolean to validate.
        Throws:
        java.lang.IllegalArgumentException - If b is false.
      • isTrue

        public static void isTrue​(boolean b,
                                  java.lang.String message,
                                  java.lang.Object... args)
                           throws java.lang.IllegalArgumentException
        Validates that b is true.
        Parameters:
        b - The boolean to validate.
        message - The message of the thrown exception.
        args - The arguments to pass to String.format(String, Object...).
        Throws:
        java.lang.IllegalArgumentException - If b is false.
      • isFalse

        public static void isFalse​(boolean b)
                            throws java.lang.IllegalArgumentException
        Validates that b is false.
        Parameters:
        b - The boolean to validate.
        Throws:
        java.lang.IllegalArgumentException - If b is true.
      • isFalse

        public static void isFalse​(boolean b,
                                   java.lang.String message,
                                   java.lang.Object... args)
                            throws java.lang.IllegalArgumentException
        Validates that b is false.
        Parameters:
        b - The boolean to validate.
        message - The message of the thrown exception.
        args - The arguments to pass to String.format(String, Object...).
        Throws:
        java.lang.IllegalArgumentException - If b is true.
      • isEqualTo

        public static VCSFile isEqualTo​(VCSFile file,
                                        VCSFile compare)
                                 throws java.lang.NullPointerException,
                                        java.lang.IllegalArgumentException
        Validates that file is equal to compare. Two files are equal if the ids of their revisions (see Revision.getId()) and their relative paths (see VCSFile.getRelativePath()) are equal.
        Parameters:
        file - The file to validate.
        compare - The file to compare to file.
        Returns:
        file, never a value != compare.
        Throws:
        java.lang.NullPointerException - If any of the given arguments is null.
        java.lang.IllegalArgumentException - If file and compare are not equals.
      • isEqualTo

        public static VCSFile isEqualTo​(VCSFile file,
                                        VCSFile compare,
                                        java.lang.String message,
                                        java.lang.Object... args)
                                 throws java.lang.NullPointerException,
                                        java.lang.IllegalArgumentException
        Validates that file is equal to compare. Two files are equal if the ids of their revisions (see Revision.getId()) and their relative paths (see VCSFile.getRelativePath()) are equal.
        Parameters:
        file - The file to validate.
        compare - The file to compare to file.
        message - The message of the thrown exception.
        args - The arguments to pass to String.format(String, Object...).
        Returns:
        file, never a value != compare.
        Throws:
        java.lang.NullPointerException - If any of the given arguments is null.
        java.lang.IllegalArgumentException - If file and compare are not equals.
      • validateState

        public static void validateState​(boolean expression)
                                  throws java.lang.IllegalStateException
        Validates that expression is true.
        Parameters:
        expression - The expression to validate.
        Throws:
        java.lang.IllegalStateException - If the expression evaluates to false.
      • validateState

        public static void validateState​(boolean expression,
                                         java.lang.String message,
                                         java.lang.Object... args)
                                  throws java.lang.IllegalStateException
        Validates that expression is true.
        Parameters:
        expression - The expression to validate.
        message - The message of the thrown exception.
        args - The arguments to pass to String.format(String, Object...).
        Throws:
        java.lang.IllegalStateException - If the expression evaluates to false.
      • fail

        public static void fail()
                         throws java.lang.IllegalStateException
        Throws a IllegalStateException.
        Throws:
        java.lang.IllegalStateException - Thrown by this method.
      • fail

        public static void fail​(java.lang.String message,
                                java.lang.Object... args)
        Throws a IllegalStateException.
        Parameters:
        message - The message of the thrown exception.
        args - The arguments to pass to String.format(String, Object...).
        Throws:
        java.lang.IllegalStateException - Thrown by this method.