Class Validate
- java.lang.Object
-
- de.unibremen.informatik.st.libvcs4j.Validate
-
public class Validate extends java.lang.Object
Utility class to validate input parameters and the current state. In order to distinguishnull
parameters and a parameters containingnull
aNullPointerException
andIllegalArgumentException
is thrown respectively.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
fail()
Throws aIllegalStateException
.static void
fail(java.lang.String message, java.lang.Object... args)
Throws aIllegalStateException
.static java.lang.String
hasPattern(java.lang.String s, java.lang.String pattern)
Validates thats
matchespattern
usingString.matches(String)
.static java.lang.String
hasPattern(java.lang.String s, java.lang.String pattern, java.lang.String message, java.lang.Object... args)
Validates thats
matchespattern
usingString.matches(String)
.static <T extends java.lang.Comparable<T>>
ThasRange(T t, T from, T to)
Validates thatfrom <= t <= to
.static <T extends java.lang.Comparable<T>>
ThasRange(T t, T from, T to, java.lang.String message, java.lang.Object... args)
Validates thatfrom <= t <= to
.static VCSFile
isEqualTo(VCSFile file, VCSFile compare)
Validates thatfile
is equal tocompare
.static VCSFile
isEqualTo(VCSFile file, VCSFile compare, java.lang.String message, java.lang.Object... args)
Validates thatfile
is equal tocompare
.static <T extends java.lang.Comparable<T>>
TisEqualTo(T t, T compare)
Validates thatt.compareTo(compare) == 0
.static <T extends java.lang.Comparable<T>>
TisEqualTo(T t, T compare, java.lang.String message, java.lang.Object... args)
Validates thatt.compareTo(compare) == 0
.static void
isFalse(boolean b)
Validates thatb
isfalse
.static void
isFalse(boolean b, java.lang.String message, java.lang.Object... args)
Validates thatb
isfalse
.static <T extends java.lang.Comparable<T>>
TisGreaterThan(T t, T compare)
Validates thatt > compare
.static <T extends java.lang.Comparable<T>>
TisGreaterThan(T t, T compare, java.lang.String message, java.lang.Object... args)
Validates thatt > compare
.static <T extends java.lang.Comparable<T>>
TisGreaterThanOrEquals(T t, T compare)
Validates thatt >= compare
.static <T extends java.lang.Comparable<T>>
TisGreaterThanOrEquals(T t, T compare, java.lang.String message, java.lang.Object... args)
Validates thatt >= compare
.static <T extends java.lang.Comparable<T>>
TisLessThan(T t, T compare)
Validates thatt.compareTo(compare) < 0
.static <T extends java.lang.Comparable<T>>
TisLessThan(T t, T compare, java.lang.String message, java.lang.Object... args)
Validates thatt.compareTo(compare) < 0
.static <T extends java.lang.Comparable<T>>
TisLessThanOrEquals(T t, T compare)
Validates thatt.compareTo(compare) <= 0
.static <T extends java.lang.Comparable<T>>
TisLessThanOrEquals(T t, T compare, java.lang.String message, java.lang.String args)
Validates thatt.compareTo(compare) <= 0
.static double
isNegative(double d)
Validates thatd
is negative.static double
isNegative(double d, java.lang.String message, java.lang.Object... args)
Validates thatd
is negative.static int
isNegative(int i)
Validates thati
is negative.static int
isNegative(int i, java.lang.String message, java.lang.Object... args)
Validates thati
is negative.static double
isPositive(double d)
Validates thatd
is positive (> 0
).static double
isPositive(double d, java.lang.String message, java.lang.Object... args)
Validates thatd
is positive (> 0
).static int
isPositive(int i)
Validates thati
is positive (> 0
).static int
isPositive(int i, java.lang.String message, java.lang.Object... args)
Validates thati
is positive (> 0
).static void
isTrue(boolean b)
Validates thatb
istrue
.static void
isTrue(boolean b, java.lang.String message, java.lang.Object... args)
Validates thatb
istrue
.static <T extends java.util.Collection<?>>
TnoNullElements(T t)
Validates thatt
is notnull
and does not containnull
values.static <T extends java.util.Collection<?>>
TnoNullElements(T t, java.lang.String message, java.lang.Object... args)
Validates thatt
is notnull
and does not containnull
values.static java.lang.String
notBlank(java.lang.String s)
Validates thats
is notnull
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 thats
is notnull
and contains at least one non-space character.static java.lang.String
notEmpty(java.lang.String s)
Validates thats
is notnull
and not empty.static java.lang.String
notEmpty(java.lang.String s, java.lang.String message, java.lang.Object... args)
Validates thats
is notnull
and not empty.static <T extends java.util.Collection<?>>
TnotEmpty(T t)
Validates thatt
is notnull
, does not containnull
values, and is not empty.static <T extends java.util.Collection<?>>
TnotEmpty(T t, java.lang.String message, java.lang.Object... args)
Validates thatt
is notnull
, does not containnull
values, and is not empty.static <T extends java.lang.Comparable<T>>
TnotEquals(T t, T compare)
Validates thatt.compareTo(compare) != 0
.static <T extends java.lang.Comparable<T>>
TnotEquals(T t, T compare, java.lang.String message, java.lang.Object... args)
Validates thatt.compareTo(compare) != 0
.static double
notNegative(double d)
Validates thatd
is not negative.static double
notNegative(double d, java.lang.String message, java.lang.Object... args)
Validates thatd
is not negative.static int
notNegative(int i)
Validates thati
is not negative.static int
notNegative(int i, java.lang.String message, java.lang.Object... args)
Validates thati
is not negative.static <T> T
notNull(T t)
Validates thatt
is notnull
.static <T> T
notNull(T t, java.lang.String message, java.lang.Object... args)
Validates thatt
is notnull
.static void
validateState(boolean expression)
Validates thatexpression
istrue
.static void
validateState(boolean expression, java.lang.String message, java.lang.Object... args)
Validates thatexpression
istrue
.
-
-
-
Method Detail
-
notNull
public static <T> T notNull(T t) throws java.lang.NullPointerException
Validates thatt
is notnull
.- Type Parameters:
T
- The type oft
.- Parameters:
t
- The value to validate.- Returns:
t
, nevernull
.- Throws:
java.lang.NullPointerException
- Ift
isnull
.
-
notNull
public static <T> T notNull(T t, java.lang.String message, java.lang.Object... args) throws java.lang.NullPointerException
Validates thatt
is notnull
.- Type Parameters:
T
- The type oft
.- Parameters:
t
- The value to validate.message
- The message of the thrown exception.args
- The arguments to pass toString.format(String, Object...)
.- Returns:
t
, nevernull
.- Throws:
java.lang.NullPointerException
- Ift
isnull
.
-
noNullElements
public static <T extends java.util.Collection<?>> T noNullElements(T t) throws java.lang.NullPointerException, java.lang.IllegalArgumentException
Validates thatt
is notnull
and does not containnull
values.- Type Parameters:
T
- The type oft
.- Parameters:
t
- The value to validate.- Returns:
t
, nevernull
.- Throws:
java.lang.NullPointerException
- Ift
isnull
.java.lang.IllegalArgumentException
- Ift
containsnull
.
-
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 thatt
is notnull
and does not containnull
values.- Type Parameters:
T
- The type oft
.- Parameters:
t
- The value to validate.message
- The message of the thrown exception.args
- The arguments to pass toString.format(String, Object...)
.- Returns:
t
, nevernull
.- Throws:
java.lang.NullPointerException
- Ift
isnull
.java.lang.IllegalArgumentException
- Ift
containsnull
.
-
noNullElements
public static <T extends java.util.Map<?,?>> T noNullElements(T t)
Validates thatt
is notnull
and does not containnull
keys and values.- Type Parameters:
T
- The type oft
.- Parameters:
t
- The value to validate.- Returns:
t
, nevernull
.- Throws:
java.lang.NullPointerException
- Ift
isnull
.java.lang.IllegalArgumentException
- Ift
containsnull
keys or values.
-
noNullElements
public static <T extends java.util.Map<?,?>> T noNullElements(T t, java.lang.String message, java.lang.Object... args)
Validates thatt
is notnull
and does not containnull
keys and values.- Type Parameters:
T
- The type oft
.- Parameters:
t
- The value to validate.message
- The message of the thrown exception.args
- The arguments to pass toString.format(String, Object...)
.- Returns:
t
, nevernull
.- Throws:
java.lang.NullPointerException
- Ift
isnull
.java.lang.IllegalArgumentException
- Ift
containsnull
keys or values.
-
notEmpty
public static <T extends java.util.Collection<?>> T notEmpty(T t) throws java.lang.NullPointerException, java.lang.IllegalArgumentException
Validates thatt
is notnull
, does not containnull
values, and is not empty.- Type Parameters:
T
- The type oft
.- Parameters:
t
- The value to validate.- Returns:
t
, nevernull
.- Throws:
java.lang.NullPointerException
- Ift
isnull
.java.lang.IllegalArgumentException
- Ift
containsnull
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 thatt
is notnull
, does not containnull
values, and is not empty.- Type Parameters:
T
- The type oft
.- Parameters:
t
- The value to validate.message
- The message of the thrown exception.args
- The arguments to pass toString.format(String, Object...)
.- Returns:
t
, nevernull
.- Throws:
java.lang.NullPointerException
- Ift
isnull
.java.lang.IllegalArgumentException
- Ift
containsnull
or is empty.
-
notEmpty
public static java.lang.String notEmpty(java.lang.String s) throws java.lang.NullPointerException, java.lang.IllegalArgumentException
Validates thats
is notnull
and not empty.- Parameters:
s
- The string to validate.- Returns:
s
, nevernull
.- Throws:
java.lang.NullPointerException
- Ifs
isnull
.java.lang.IllegalArgumentException
- Ifs
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 thats
is notnull
and not empty.- Parameters:
s
- The string to validate.message
- The message of the thrown exception.args
- The arguments to pass toString.format(String, Object...)
.- Returns:
s
, nevernull
.- Throws:
java.lang.NullPointerException
- Ifs
isnull
.java.lang.IllegalArgumentException
- Ifs
is empty.
-
notBlank
public static java.lang.String notBlank(java.lang.String s) throws java.lang.NullPointerException, java.lang.IllegalArgumentException
Validates thats
is notnull
and contains at least one non-space character.- Parameters:
s
- The string to validate.- Returns:
s
, never a value that isnull
or consists of spaces only.- Throws:
java.lang.NullPointerException
- Ifs
isnull
.java.lang.IllegalArgumentException
- Ifs
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 thats
is notnull
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 toString.format(String, Object...)
.- Returns:
s
, never a value that isnull
or consists of spaces only.- Throws:
java.lang.NullPointerException
- Ifs
isnull
.java.lang.IllegalArgumentException
- Ifs
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 thats
matchespattern
usingString.matches(String)
.- Parameters:
s
- The string to validate.pattern
- The pattern to match.- Returns:
s
, never a value that doesn't matchpattern
.- Throws:
java.lang.NullPointerException
- If any of the given arguments isnull
.java.lang.IllegalArgumentException
- Ifs
does not matchpattern
.
-
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 thats
matchespattern
usingString.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 toString.format(String, Object...)
.- Returns:
s
, never a value that doesn't matchpattern
.- Throws:
java.lang.NullPointerException
- If any of the given arguments isnull
.java.lang.IllegalArgumentException
- Ifs
does not matchpattern
.
-
notNegative
public static int notNegative(int i) throws java.lang.IllegalArgumentException
Validates thati
is not negative.- Parameters:
i
- The integer to validate.- Returns:
i
, never a negative value.- Throws:
java.lang.IllegalArgumentException
- Ifi < 0
.
-
notNegative
public static int notNegative(int i, java.lang.String message, java.lang.Object... args) throws java.lang.IllegalArgumentException
Validates thati
is not negative.- Parameters:
i
- The integer to validate.message
- The message of the thrown exception.args
- The arguments to pass toString.format(String, Object...)
.- Returns:
i
, never a negative value.- Throws:
java.lang.IllegalArgumentException
- Ifi < 0
.
-
notNegative
public static double notNegative(double d) throws java.lang.IllegalArgumentException
Validates thatd
is not negative.- Parameters:
d
- The double to validate.- Returns:
d
, never a negative value.- Throws:
java.lang.IllegalArgumentException
- Ifd < 0
.
-
notNegative
public static double notNegative(double d, java.lang.String message, java.lang.Object... args) throws java.lang.IllegalArgumentException
Validates thatd
is not negative.- Parameters:
d
- The double to validate.message
- The message of the thrown exception.args
- The arguments to pass toString.format(String, Object...)
.- Returns:
d
, never a negative value.- Throws:
java.lang.IllegalArgumentException
- Ifd < 0
.
-
isNegative
public static int isNegative(int i) throws java.lang.IllegalArgumentException
Validates thati
is negative.- Parameters:
i
- The integer to validate.- Returns:
i
, never a value>= 0
.- Throws:
java.lang.IllegalArgumentException
- Ifi >= 0
.
-
isNegative
public static int isNegative(int i, java.lang.String message, java.lang.Object... args) throws java.lang.IllegalArgumentException
Validates thati
is negative.- Parameters:
i
- The integer to validate.message
- The message of the thrown exception.args
- The arguments to pass toString.format(String, Object...)
.- Returns:
i
, never a value>= 0
.- Throws:
java.lang.IllegalArgumentException
- Ifi >= 0
.
-
isNegative
public static double isNegative(double d) throws java.lang.IllegalArgumentException
Validates thatd
is negative.- Parameters:
d
- The double to validate.- Returns:
d
, never a value>= 0
.- Throws:
java.lang.IllegalArgumentException
- Ifd >= 0
.
-
isNegative
public static double isNegative(double d, java.lang.String message, java.lang.Object... args) throws java.lang.IllegalArgumentException
Validates thatd
is negative.- Parameters:
d
- The double to validate.message
- The message of the thrown exception.args
- The arguments to pass toString.format(String, Object...)
.- Returns:
d
, never a value>= 0
.- Throws:
java.lang.IllegalArgumentException
- Ifd >= 0
.
-
isPositive
public static int isPositive(int i) throws java.lang.IllegalArgumentException
Validates thati
is positive (> 0
).- Parameters:
i
- The integer to validate.- Returns:
i
, never a value<= 0
.- Throws:
java.lang.IllegalArgumentException
- Ifi <= 0
.
-
isPositive
public static int isPositive(int i, java.lang.String message, java.lang.Object... args) throws java.lang.IllegalArgumentException
Validates thati
is positive (> 0
).- Parameters:
i
- The integer to validate.message
- The message of the thrown exception.args
- The arguments to pass toString.format(String, Object...)
.- Returns:
i
, never a value<= 0
.- Throws:
java.lang.IllegalArgumentException
- Ifi <= 0
.
-
isPositive
public static double isPositive(double d) throws java.lang.IllegalArgumentException
Validates thatd
is positive (> 0
).- Parameters:
d
- The double to validate.- Returns:
d
, never a value<= 0
.- Throws:
java.lang.IllegalArgumentException
- Ifd <= 0
.
-
isPositive
public static double isPositive(double d, java.lang.String message, java.lang.Object... args) throws java.lang.IllegalArgumentException
Validates thatd
is positive (> 0
).- Parameters:
d
- The double to validate.message
- The message of the thrown exception.args
- The arguments to pass toString.format(String, Object...)
.- Returns:
d
, never a value<= 0
.- Throws:
java.lang.IllegalArgumentException
- Ifd <= 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 thatfrom <= t <= to
.- Type Parameters:
T
- The type oft
,from
, andto
.- 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 isnull
.java.lang.IllegalArgumentException
- Ift < from
ort > 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 thatfrom <= t <= to
.- Type Parameters:
T
- The type oft
,from
, andto
.- 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 toString.format(String, Object...)
.- Returns:
t
, never a value< from
or> to
.- Throws:
java.lang.NullPointerException
- If any of the given arguments isnull
.java.lang.IllegalArgumentException
- Ift < from
ort > to
.
-
isGreaterThan
public static <T extends java.lang.Comparable<T>> T isGreaterThan(T t, T compare) throws java.lang.NullPointerException, java.lang.IllegalArgumentException
Validates thatt > compare
.- Type Parameters:
T
- The type oft
andcompare
.- Parameters:
t
- The value to validate.compare
- The value to compare tot
.- Returns:
t
, never a value<= compare
- Throws:
java.lang.NullPointerException
- If any of the given arguments isnull
.java.lang.IllegalArgumentException
- Ift <= 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 thatt > compare
.- Type Parameters:
T
- The type oft
andcompare
.- Parameters:
t
- The value to validate.compare
- The value to compare tot
.message
- The message of the thrown exception.args
- The arguments to pass toString.format(String, Object...)
.- Returns:
t
, never a value<= compare
- Throws:
java.lang.NullPointerException
- If any of the given arguments isnull
.java.lang.IllegalArgumentException
- Ift <= compare
.
-
isGreaterThanOrEquals
public static <T extends java.lang.Comparable<T>> T isGreaterThanOrEquals(T t, T compare) throws java.lang.NullPointerException, java.lang.IllegalArgumentException
Validates thatt >= compare
.- Type Parameters:
T
- The type oft
andcompare
.- Parameters:
t
- The value to validate.compare
- The value to compare tot
.- Returns:
t
, never a value< compare
.- Throws:
java.lang.NullPointerException
- If any of the given arguments isnull
.java.lang.IllegalArgumentException
- Ift < 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 thatt >= compare
.- Type Parameters:
T
- The type oft
andcompare
.- Parameters:
t
- The value to validate.compare
- The value to compare tot
.message
- The message of the thrown exception.args
- The arguments to pass toString.format(String, Object...)
.- Returns:
t
, never a value< compare
.- Throws:
java.lang.NullPointerException
- If any of the given arguments isnull
.java.lang.IllegalArgumentException
- Ift < compare
.
-
isEqualTo
public static <T extends java.lang.Comparable<T>> T isEqualTo(T t, T compare) throws java.lang.NullPointerException, java.lang.IllegalArgumentException
Validates thatt.compareTo(compare) == 0
.- Type Parameters:
T
- The type oft
andcompare
.- Parameters:
t
- The value to validate.compare
- The value to compare tot
.- Returns:
t
, never a value!= compare
.- Throws:
java.lang.NullPointerException
- If any of the given arguments isnull
.java.lang.IllegalArgumentException
- Ift.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 thatt.compareTo(compare) == 0
.- Type Parameters:
T
- The type oft
andcompare
.- Parameters:
t
- The value to validate.compare
- The value to compare tot
.message
- The message of the thrown exception.args
- The arguments to pass toString.format(String, Object...)
.- Returns:
t
, never a value!= compare
.- Throws:
java.lang.NullPointerException
- If any of the given arguments isnull
.java.lang.IllegalArgumentException
- Ift.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 thatt.compareTo(compare) != 0
.- Type Parameters:
T
- The type oft
andcompare
.- Parameters:
t
- The value to validate.compare
- The value to compare tot
.- Returns:
t
, never a value== compare
.- Throws:
java.lang.NullPointerException
- If any of the given arguments isnull
.java.lang.IllegalArgumentException
- Ift.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 thatt.compareTo(compare) != 0
.- Type Parameters:
T
- The type oft
andcompare
.- Parameters:
t
- The value to validate.compare
- The value to compare tot
.message
- The message of the thrown exception.args
- The arguments to pass toString.format(String, Object...)
.- Returns:
t
, never a value== compare
.- Throws:
java.lang.NullPointerException
- If any of the given arguments isnull
.java.lang.IllegalArgumentException
- Ift.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 thatt.compareTo(compare) <= 0
.- Type Parameters:
T
- The type oft
andcompare
.- Parameters:
t
- The value to validate.compare
- The value to compare tot
.- Returns:
t
, never a value> compare
.- Throws:
java.lang.NullPointerException
- If any of the given arguments isnull
.java.lang.IllegalArgumentException
- Ift.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 thatt.compareTo(compare) <= 0
.- Type Parameters:
T
- The type oft
andcompare
.- Parameters:
t
- The value to validate.compare
- The value to compare tot
.message
- The message of the thrown exception.args
- The arguments to pass toString.format(String, Object...)
.- Returns:
t
, never a value> compare
.- Throws:
java.lang.NullPointerException
- If any of the given arguments isnull
.java.lang.IllegalArgumentException
- Ift.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 thatt.compareTo(compare) < 0
.- Type Parameters:
T
- The type oft
andcompare
.- Parameters:
t
- The value to validate.compare
- The value to compare tot
.- Returns:
t
, never a value>= compare
.- Throws:
java.lang.NullPointerException
- If any of the given arguments isnull
.java.lang.IllegalArgumentException
- Ift.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 thatt.compareTo(compare) < 0
.- Type Parameters:
T
- The type oft
andcompare
.- Parameters:
t
- The value to validate.compare
- The value to compare tot
.message
- The message of the thrown exception.args
- The arguments to pass toString.format(String, Object...)
.- Returns:
t
, never a value>= compare
.- Throws:
java.lang.NullPointerException
- If any of the given arguments isnull
.java.lang.IllegalArgumentException
- Ift.compareTo(compare) >= 0
.
-
isTrue
public static void isTrue(boolean b) throws java.lang.IllegalArgumentException
Validates thatb
istrue
.- Parameters:
b
- The boolean to validate.- Throws:
java.lang.IllegalArgumentException
- Ifb
isfalse
.
-
isTrue
public static void isTrue(boolean b, java.lang.String message, java.lang.Object... args) throws java.lang.IllegalArgumentException
Validates thatb
istrue
.- Parameters:
b
- The boolean to validate.message
- The message of the thrown exception.args
- The arguments to pass toString.format(String, Object...)
.- Throws:
java.lang.IllegalArgumentException
- Ifb
isfalse
.
-
isFalse
public static void isFalse(boolean b) throws java.lang.IllegalArgumentException
Validates thatb
isfalse
.- Parameters:
b
- The boolean to validate.- Throws:
java.lang.IllegalArgumentException
- Ifb
istrue
.
-
isFalse
public static void isFalse(boolean b, java.lang.String message, java.lang.Object... args) throws java.lang.IllegalArgumentException
Validates thatb
isfalse
.- Parameters:
b
- The boolean to validate.message
- The message of the thrown exception.args
- The arguments to pass toString.format(String, Object...)
.- Throws:
java.lang.IllegalArgumentException
- Ifb
istrue
.
-
isEqualTo
public static VCSFile isEqualTo(VCSFile file, VCSFile compare) throws java.lang.NullPointerException, java.lang.IllegalArgumentException
Validates thatfile
is equal tocompare
. Two files are equal if the ids of their revisions (seeRevision.getId()
) and their relative paths (seeVCSFile.getRelativePath()
) are equal.- Parameters:
file
- The file to validate.compare
- The file to compare tofile
.- Returns:
file
, never a value!= compare
.- Throws:
java.lang.NullPointerException
- If any of the given arguments isnull
.java.lang.IllegalArgumentException
- Iffile
andcompare
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 thatfile
is equal tocompare
. Two files are equal if the ids of their revisions (seeRevision.getId()
) and their relative paths (seeVCSFile.getRelativePath()
) are equal.- Parameters:
file
- The file to validate.compare
- The file to compare tofile
.message
- The message of the thrown exception.args
- The arguments to pass toString.format(String, Object...)
.- Returns:
file
, never a value!= compare
.- Throws:
java.lang.NullPointerException
- If any of the given arguments isnull
.java.lang.IllegalArgumentException
- Iffile
andcompare
are not equals.
-
validateState
public static void validateState(boolean expression) throws java.lang.IllegalStateException
Validates thatexpression
istrue
.- Parameters:
expression
- The expression to validate.- Throws:
java.lang.IllegalStateException
- If the expression evaluates tofalse
.
-
validateState
public static void validateState(boolean expression, java.lang.String message, java.lang.Object... args) throws java.lang.IllegalStateException
Validates thatexpression
istrue
.- Parameters:
expression
- The expression to validate.message
- The message of the thrown exception.args
- The arguments to pass toString.format(String, Object...)
.- Throws:
java.lang.IllegalStateException
- If the expression evaluates tofalse
.
-
fail
public static void fail() throws java.lang.IllegalStateException
Throws aIllegalStateException
.- Throws:
java.lang.IllegalStateException
- Thrown by this method.
-
fail
public static void fail(java.lang.String message, java.lang.Object... args)
Throws aIllegalStateException
.- Parameters:
message
- The message of the thrown exception.args
- The arguments to pass toString.format(String, Object...)
.- Throws:
java.lang.IllegalStateException
- Thrown by this method.
-
-