|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.mozilla.util.ParameterCheck
public final class ParameterCheck
ParameterCheck provides convenient means for parameter checking. Class methods in the ParameterCheck class can be used to verify that method parameters meet certain conditions and to raise exceptions if the conditions are not met.
Typical usage:
ParameterCheck.nonNull(myParameter);
This verifies that myParameter is not null, throwing an IllegalArgumentException if it is.
ParameterCheck is intended specifically for checking parameters; for general condition and invariant testing, use Assert.
Assert
Method Summary | |
---|---|
static void |
greaterThan(double aDouble,
double minimum)
Throws RangeException if 'aDouble' is not greater than 'minimum'; otherwise, does nothing. |
static void |
greaterThan(int anInt,
int minimum)
Throws RangeException if 'anInt' is not greater than 'minimum'; otherwise, does nothing. |
static void |
isFalse(boolean generalTest,
java.lang.String message)
Identical to isTrue, except the test is inverted. |
static void |
isTrue(boolean generalTest,
java.lang.String message)
Throws IllegalArgumentException if 'generalTest' is false; otherwise, does nothing. |
static void |
lessThan(double aDouble,
double maximum)
Throws RangeException if 'aDouble' is not less than 'maximum'; otherwise, does nothing. |
static void |
lessThan(int anInt,
int maximum)
Throws RangeException if 'anInt' is not less than 'maximum'; otherwise, does nothing. |
static void |
noGreaterThan(double aDouble,
double maximum)
Throws RangeException if 'aDouble' is greater than 'maximum'; otherwise, does nothing. |
static void |
noGreaterThan(int anInt,
int maximum)
Throws RangeException if 'anInt' is greater than 'maximum'; otherwise, does nothing. |
static void |
noLessThan(double aDouble,
double minimum)
Throws RangeException if 'aDouble' is less than 'minimum'; otherwise, does nothing. |
static void |
noLessThan(int anInt,
int minimum)
Throws RangeException if 'anInt' is less than 'minimum'; otherwise, does nothing. |
static void |
nonNull(java.lang.Object anObject)
Throws IllegalArgumentException if 'anObject' is null; otherwise, does nothing. |
static void |
notEmpty(java.lang.String aString)
Throws IllegalArgumentException if 'aString' is null or if 'aString' is an empty string; otherwise, does nothing. |
static void |
rangeWithinBounds(Range aRange,
int minimum,
int maximum)
Throws RangeException if 'aRange' is not completely between 'minimum' and 'maximum', inclusive; otherwise, does nothing. |
static void |
rangeWithinCount(Range aRange,
int count)
Throws RangeException if 'aRange' is not completely within a sequence that starts at 0 and has a length of 'count'; otherwise does nothing. |
static void |
rangeWithinString(Range aRange,
java.lang.String aString)
Checks a string and a range which is intended to indicate a substring. |
static void |
withinCount(int anInt,
int count)
Throws RangeException if 'anInt' is not within a sequence that starts at 0 and has a length of 'count'; otherwise does nothing. |
static void |
withinRange(double aDouble,
double minimum,
double maximum)
Throws RangeException if 'aDouble' is less than 'minimum' or greater than 'maximum'; otherwise, does nothing. |
static void |
withinRange(int anInt,
int minimum,
int maximum)
Throws RangeException if 'anInt' is less than 'minimum' or greater than 'maximum'; otherwise, does nothing. |
static void |
withinRange(int anInt,
Range aRange)
Throws RangeException if 'anInt' is not within 'aRange'; otherwise, does nothing. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void nonNull(java.lang.Object anObject)
anObject
- value to verify as non-null
java.lang.IllegalArgumentException
- if 'anObject' is nullpublic static void notEmpty(java.lang.String aString)
aString
- string to verify as non-null and not empty
java.lang.IllegalArgumentException
- if 'aString' is null or emptypublic static void noLessThan(int anInt, int minimum)
anInt
- value to verify as not less than 'minimum'minimum
- smallest acceptable value for 'anInt'
RangeException
- if 'anInt' is less than 'minimum'public static void greaterThan(int anInt, int minimum)
anInt
- value to verify as greater than 'minimum'minimum
- largest unacceptable value for 'anInt'
RangeException
- if 'anInt' is not greater than 'minimum'public static void noGreaterThan(int anInt, int maximum)
anInt
- value to verify as not greater than 'maximum'maximum
- largest acceptable value for 'anInt'
RangeException
- if 'anInt' is greater than 'maximum'public static void lessThan(int anInt, int maximum)
anInt
- value to verify as less than 'minimum'maximum
- smallest unacceptable value for 'anInt'
RangeException
- if 'anInt' is not less than 'maximum'public static void noLessThan(double aDouble, double minimum)
aDouble
- value to verify as not less than 'minimum'minimum
- smallest acceptable value for 'aDouble'
RangeException
- if 'aDouble' is less than 'minimum'public static void greaterThan(double aDouble, double minimum)
aDouble
- value to verify as greater than 'minimum'minimum
- largest unacceptable value for 'aDouble'
RangeException
- if 'aDouble' is not greater than 'minimum'public static void noGreaterThan(double aDouble, double maximum)
aDouble
- value to verify as not greater than 'maximum'maximum
- largest acceptable value for 'aDouble'
RangeException
- if 'aDouble' is greater than 'maximum'public static void lessThan(double aDouble, double maximum)
aDouble
- value to verify as less than 'minimum'maximum
- smallest unacceptable value for 'aDouble'
RangeException
- if 'aDouble' is not less than 'maximum'public static void withinRange(int anInt, int minimum, int maximum)
anInt
- value to verify as not greater than 'maximum' and
not less than 'minimum'minimum
- smallest acceptable value for 'anInt'maximum
- largest acceptable value for 'anInt'
RangeException
- if 'anInt' is less than 'minimum' or
greater than 'maximum'public static void withinRange(double aDouble, double minimum, double maximum)
aDouble
- value to verify as not greater than 'maximum' and
not less than 'minimum'minimum
- smallest acceptable value for 'aDouble'maximum
- largest acceptable value for 'aDouble'
RangeException
- if 'aDouble' is less than 'minimum' or
greater than 'maximum'public static void withinRange(int anInt, Range aRange)
anInt
- value to verify as within 'aRange'aRange
- acceptable range for 'anInt'
RangeException
- if 'anInt' is not within 'aRange'public static void withinCount(int anInt, int count)
anInt
- value to verify as between 0 and 'count' - 1, inclusivecount
- length of sequence
RangeException
- if 'anInt' is out of boundspublic static void rangeWithinBounds(Range aRange, int minimum, int maximum)
aRange
- range to verify as between 'minimum' and 'maximum'minimum
- smallest acceptable index in 'aRange'maximum
- largest acceptable index in 'aRange'
RangeException
- if 'aRange' is out of boundspublic static void rangeWithinCount(Range aRange, int count)
aRange
- range to verify as between 0 and 'count' - 1, inclusivecount
- length of sequence
RangeException
- if 'aRange' is out of boundspublic static void rangeWithinString(Range aRange, java.lang.String aString)
aRange
- A range which must be contained within
the string.aString
- A string to use for verifying the range.
java.lang.IllegalArgumentException
- if either argument is null
RangeException
- if the range is not contained
within the stringpublic static void isTrue(boolean generalTest, java.lang.String message)
generalTest
- value to verify as truemessage
- message describing the failure
java.lang.IllegalArgumentException
- if 'generalTest' is falseisFalse(boolean generalTest, String message)
public static void isFalse(boolean generalTest, java.lang.String message)
generalTest
- value to verify as falsemessage
- message describing the failure
java.lang.IllegalArgumentException
- if 'generalTest' is falseisTrue(boolean generalTest, String message)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |