public class Assert extends Object
Constructor and Description |
---|
Assert() |
Modifier and Type | Method and Description |
---|---|
static <T,E extends RuntimeException> |
cast(Object obj,
Class<T> clazz,
String info,
Class<E> throwable)
Tests to see if the object can be cast to the specified type.
|
static <E extends RuntimeException> |
inRange(int n,
int from,
int to,
String info,
Class<E> clazz)
Note: asserts n is in the range from->to, inclusive.
|
static <E extends RuntimeException> |
inRange(long n,
long from,
long to,
String info,
Class<E> clazz) |
static <E extends RuntimeException> |
isEquivalent(byte[] a,
byte[] b)
assert identical based on content.
|
static <E extends RuntimeException> |
isEquivalent(byte[] a,
byte[] b,
Class<E> clazz)
assert identical based on content.
|
static <E extends RuntimeException> |
isTrue(boolean fact,
Class<E> clazz)
Usage:
|
static <E extends RuntimeException> |
isTrue(boolean fact,
String claim,
Class<E> clazz)
Usage:
|
static <T,E extends RuntimeException> |
notNull(T obj,
Class<E> clazz)
Usage:
|
static <T,E extends RuntimeException> |
notNull(T obj,
int idx,
Class<E> clazz) |
static <T,E extends RuntimeException> |
notNull(T obj,
String info,
Class<E> clazz)
Usage:
|
public static final <E extends RuntimeException> void isEquivalent(byte[] a, byte[] b)
E
- a
- b
- clazz
- public static final <E extends RuntimeException> void isEquivalent(byte[] a, byte[] b, Class<E> clazz)
E
- a
- b
- clazz
- public static final <T,E extends RuntimeException> T notNull(T obj, Class<E> clazz) throws E extends RuntimeException
// ... somewhere within the bowels of your code ..
//
Assert.notNull (aReference, YourRuntimeException.class);
T
- E
- obj
- clazz
- E
E extends RuntimeException
public static final <T,E extends RuntimeException> T notNull(T obj, String info, Class<E> clazz) throws E extends RuntimeException
// ... somewhere within the bowels of your code ..
//
Assert.notNull (inputRecord, "inputRecord", YourRuntimeException.class);
T
- E
- obj
- info
- clazz
- E
E extends RuntimeException
public static final <T,E extends RuntimeException> T notNull(T obj, int idx, Class<E> clazz) throws E extends RuntimeException
E extends RuntimeException
public static final <E extends RuntimeException> void isTrue(boolean fact, String claim, Class<E> clazz) throws E extends RuntimeException
// ... somewhere within the bowels of your code ..
//
Assert.isTrue (conn.isReady(), "connection is ready", YourRuntimeException.class);
E
- fact
- claim
- clazz
- E
E extends RuntimeException
public static final <E extends RuntimeException> void isTrue(boolean fact, Class<E> clazz) throws E extends RuntimeException
// ... somewhere within the bowels of your code ..
//
Assert.isTrue (conn.isReady(), YourRuntimeException.class);
E
- is what you wish thrown - must be related to RuntimeException
fact
- clazz
- E
E extends RuntimeException
public static final <E extends RuntimeException> long inRange(long n, long from, long to, String info, Class<E> clazz) throws E extends RuntimeException
E
- n
- from
- to
- info
- clazz
- E
E extends RuntimeException
public static final <E extends RuntimeException> int inRange(int n, int from, int to, String info, Class<E> clazz) throws E extends RuntimeException
E
- n
- from
- to
- info
- clazz
- E
E extends RuntimeException
public static final <T,E extends RuntimeException> T cast(Object obj, Class<T> clazz, String info, Class<E> throwable) throws E extends RuntimeException
T
- the typeE
- the thrown exception typeobj
- the object to be castclazz
- of the the target typeinfo
- the message for the exception thrownthrowable
- specified if notE
E extends RuntimeException
Copyright © 2009–2016. All rights reserved.