Class Assert<T>
- java.lang.Object
-
- org.eclipse.emf.ecp.common.spi.asserts.Assert<T>
-
- Type Parameters:
T
- the type of the object theAssert
class verifies.
public final class Assert<T> extends java.lang.Object
Class for checking the validity of a provided object.- Since:
- 1.6
- Author:
- Alexandra Buzila
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description T
check()
Usage example:
Assert.create(Object object).notNull().ofClass(Class clazz).check()
.static <T> Assert<T>
create(T object)
Assert<T>
notNull()
Checks if the object is null, in which case anIllegalArgumentException
is thrown.Assert<?>
ofClass(java.lang.Class<?> clazz)
Checks if the object has a different type than the Class provided as parameter, in which case anIllegalArgumentException
is thrown.
-
-
-
Method Detail
-
create
public static <T> Assert<T> create(T object)
- Type Parameters:
T
- the type of the object theAssert
class verifies.- Parameters:
object
- the object that will be checked- Returns:
- a new instance of the
Assert
class.
-
notNull
public Assert<T> notNull()
Checks if the object is null, in which case anIllegalArgumentException
is thrown.- Returns:
- the
Assert
instance, when no exception is thrown.
-
ofClass
public Assert<?> ofClass(java.lang.Class<?> clazz)
Checks if the object has a different type than the Class provided as parameter, in which case anIllegalArgumentException
is thrown.- Parameters:
clazz
- theClass
against which the type of the object is checked.- Returns:
- the
Assert
instance, when no exception is thrown.
-
check
public T check()
Usage example:
Assert.create(Object object).notNull().ofClass(Class clazz).check()
.- Returns:
- the object for which the
Assert
is created.
-
-