Class MethodCheck
java.lang.Object
net.okapia.osid.torrefacto.util.MethodCheck
Utility to help reduce method clutter in checking state
and arguments.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final voidcardinalarg(long number, String name) Checks that the supplied number is a cardinal value.static final voidcardinalarg(BigDecimal number, String name) Checks that the supplied number is a cardinal value.static final voidcardinalrangearg(long low, long high, String lowName, String highName) Checks the supplied cardinal range.static final voiddecimalrangearg(BigDecimal low, BigDecimal high, String lowName, String highName) Checks the supplied decimal range.static final voidintegerrangearg(long low, long high, String lowName, String highName) Checks the supplied integer range.static final voidThrows an error if the given object isnull.static final voidpercentarg(long number, String name) Checks that the supplied number is between 0-100.static final voidpercentarg(BigDecimal number, String name) Checks that the supplied number is between 0-100.static final voidChecks that a value is not null.
-
Constructor Details
-
MethodCheck
public MethodCheck()Constructs a newMethodCheck.
-
-
Method Details
-
nullarg
Throws an error if the given object isnull.- Parameters:
o- an objectname- the name of the parameter to include in the exception- Throws:
NullArgumentException-oisnull
-
cardinalarg
Checks that the supplied number is a cardinal value.- Parameters:
number- the value to checkname- the name of the parameter to include in the exception- Throws:
InvalidArgumentException- ifnumberis less than zeroNullArgumentException-nameis null
-
cardinalarg
Checks that the supplied number is a cardinal value.- Parameters:
number- the value to checkname- the name of the parameter to include in the exception- Throws:
InvalidArgumentException- ifnumberis less than zeroNullArgumentException-numberornameis null
-
cardinalrangearg
Checks the supplied cardinal range.- Parameters:
low- the low end of rangehigh- the high end of rangelowName- the name of the parameter to include in the exceptionhighName- the name of the parameter to include in the exception- Throws:
InvalidArgumentException- ifloworhighis less than zero, orlowis greater thanhighNullArgumentException-lowNameorhighNameis null
-
decimalrangearg
public static final void decimalrangearg(BigDecimal low, BigDecimal high, String lowName, String highName) Checks the supplied decimal range.- Parameters:
low- the low end of rangehigh- the high end of rangelowName- the name of the parameter to include in the exceptionhighName- the name of the parameter to include in the exception- Throws:
InvalidArgumentException- ifloworhighis less than zero, orlowis greater thanhighNullArgumentException-low,lowName,high, orhighNameis null
-
integerrangearg
Checks the supplied integer range.- Parameters:
low- the low end of rangehigh- the high end of rangelowName- the name of the parameter to include in the exceptionhighName- the name of the parameter to include in the exception- Throws:
InvalidArgumentException- iflowis greater thanhighNullArgumentException-lowNameorhighNameis null
-
percentarg
Checks that the supplied number is between 0-100.- Parameters:
number- the value to checkname- the name of the parameter to include in the exception- Throws:
InvalidArgumentException- ifnumberis out of rangeNullArgumentException-nameis null
-
percentarg
Checks that the supplied number is between 0-100.- Parameters:
number- the value to checkname- the name of the parameter to include in the exception- Throws:
InvalidArgumentException- ifnumberisnullor less than zeroNullArgumentException-numberornameis null
-
unsetvar
Checks that a value is not null.- Parameters:
var- the value to checkname- the name of the parameter to include in the exception- Throws:
BadLogicException- ifvarhas not been setNullArgumentException-varornameis null
-