|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--unannoy.util.ArgCheck
Generic functions for making sure your functions are not being given garbage. This replaces the code like
if (myArg == null || myArg.length() == 0) { String error = "myArg should not be null or empty"; throw new IllegalArgumentException(error); }
with something like this
ArgCheck.notNullOrEmpty("myArg", myArg);Naturally, this is all nicely consolidated in one place, it tries to be somewhat intelligent about things and give you as precise error messages as it can
Constructor Summary | |
ArgCheck()
|
Method Summary | |
static java.lang.String |
argString(java.lang.String argName)
Returns an appropriate String to describe the name of the illegal argument (it puts quotation marks around it ; yippee) |
static java.lang.String |
argString(java.lang.String argName,
java.lang.String argValue)
Returns an appropriate String to describe the illegal argument |
static java.lang.String |
beginMessage(java.lang.String location)
Returns an appropriate String to begin the message of an IllegalArgumentException. |
static java.lang.String |
beginMessage(java.lang.String location,
java.lang.String argName)
Returns an appropriate String to begin the message of an IllegalArgumentException. |
static java.lang.String |
beginMessage(java.lang.String location,
java.lang.String argName,
java.lang.String argValue)
Returns an appropriate String to begin the message of an IllegalArgumentException. |
static void |
notNull(java.lang.String argumentName,
java.lang.Object argumentValue)
Checks that an argument is not null |
static void |
notNull(java.lang.String location,
java.lang.String argumentName,
java.lang.Object argumentValue)
Checks that an argument is not null |
static void |
notNullOrEmpty(java.lang.String argumentName,
java.lang.String argumentValue)
Checks that an argument's value is neither null or empty |
static void |
notNullOrEmpty(java.lang.String location,
java.lang.String argumentName,
java.lang.String argumentValue)
Checks that an argument's value is neither null or empty |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ArgCheck()
Method Detail |
public static void notNullOrEmpty(java.lang.String argumentName, java.lang.String argumentValue) throws NullArgumentException
argumentName
- the name or description of the argument
NullArgumentException
- if its value is null or emptypublic static void notNullOrEmpty(java.lang.String location, java.lang.String argumentName, java.lang.String argumentValue) throws NullArgumentException
location
- a description of where this check is performedargumentName
- the name or description of the argument
NullArgumentException
- if its value is null or emptypublic static void notNull(java.lang.String argumentName, java.lang.Object argumentValue) throws NullArgumentException
argumentName
- the name or description of the argument
NullArgumentException
- if its value is nullpublic static void notNull(java.lang.String location, java.lang.String argumentName, java.lang.Object argumentValue) throws NullArgumentException
location
- a description of where this check is performedargumentName
- the name or description of the argument
NullArgumentException
- if its value is nullpublic static java.lang.String beginMessage(java.lang.String location)
location
- a description of where the error occured
public static java.lang.String beginMessage(java.lang.String location, java.lang.String argName)
location
- a description of where the error occuredargName
- the name of the illegal argument
public static java.lang.String beginMessage(java.lang.String location, java.lang.String argName, java.lang.String argValue)
location
- a description of where the error occuredargName
- the name of the illegal argumentargValue
- the value of the illegal argument
public static java.lang.String argString(java.lang.String argName)
public static java.lang.String argString(java.lang.String argName, java.lang.String argValue)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |