|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.obsearch.asserts.OBAsserts
public final class OBAsserts
This class contains utility functions that help to check for conditions and create exceptions if those conditions are not met. The functions can be statically imported for convenience
Method Summary | |
---|---|
static void |
chkAssert(boolean condition,
String msg)
Creates an OBException with the given msg if the given condition is false. |
static void |
chkAssertStorage(boolean condition,
String msg)
|
static void |
chkEven(long x)
Make sure x is even. |
static void |
chkFileExists(File file)
Checks that the given file exists, otherwise throws an IOException |
static void |
chkFileExists(String file)
|
static void |
chkFileNotExists(File file)
|
static void |
chkFileNotExists(String file)
|
static void |
chkNotNull(Object x,
String msg)
|
static void |
chkParam(boolean condition,
String msg)
Creates an IllegalArgumentException with the given msg if the given condition is false. |
static void |
chkPositive(long x)
Checks if the given number is greater or equal than 0. |
static void |
chkRange(int toCheck,
int min,
int max)
Checks that the given value "toCheck" is within range [min, max]. |
static void |
chkRange(long toCheck,
long min,
long max)
Checks that the given value "toCheck" is within range [min, max]. |
static void |
chkRange(short toCheck,
short min,
short max)
Checks that the given value "toCheck" is within range [min, max]. |
static void |
fail(String msg)
Fail with the given message. |
static void |
notNull(Object x)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void chkAssert(boolean condition, String msg) throws OBException
condition
- Condition to be testedmsg
- Msg to output in the exception if condition == false
OBException
- If an error occurrs it will be wrapped in an OBExceptionpublic static void chkNotNull(Object x, String msg) throws OBException
OBException
public static void chkAssertStorage(boolean condition, String msg) throws OBStorageException
OBStorageException
public static void chkParam(boolean condition, String msg)
condition
- Condition to be testedmsg
- Msg to output in the exception if condition == falsepublic static void notNull(Object x) throws OBException
OBException
public static void chkFileExists(File file) throws OBStorageException
file
- File that will be confirmed for existence
IOException
- if the given file does not exist
OBStorageException
public static void chkFileExists(String file) throws OBStorageException
OBStorageException
public static void chkFileNotExists(String file) throws OBStorageException
OBStorageException
public static void chkFileNotExists(File file) throws OBStorageException
OBStorageException
public static void fail(String msg) throws OBException
msg
- The message to be thrown.
OBException
public static void chkRange(int toCheck, int min, int max)
toCheck
- Value to be checkedmin
- minimum boundmax
- maximum bound
IndexOutOfBoundsException
public static void chkRange(long toCheck, long min, long max)
toCheck
- Value to be checkedmin
- minimum boundmax
- maximum boundpublic static void chkPositive(long x)
x
- public static void chkEven(long x)
x
- number to verifypublic static void chkRange(short toCheck, short min, short max)
toCheck
- Value to be checkedmin
- minimum boundmax
- maximum bound
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |