Class Assertion<T extends Throwable>
- java.lang.Object
-
- org.gcube.resourcemanagement.support.shared.util.Assertion<T>
-
- All Implemented Interfaces:
com.google.gwt.user.client.rpc.IsSerializable,Serializable
public class Assertion<T extends Throwable> extends Object implements Serializable, com.google.gwt.user.client.rpc.IsSerializable
General purpose assertion handler. Assertion can be generalized to check a boolean expression and to raise an exception in correspondence to a failure happening during checking.Example: Assertion<TheExceptionType> assertion = new Assertion<ParamException> (); assertion.validate (param != null, new TheExceptionType("invalid parameter null")); or, in a more compact form: // The exception to throw in case of failure // during the evaluation of the expected condition new Assertion<TheExceptionType>().validate( i>5, // The expected boolean condition new TheExceptionType("Parameter must be greater than 5")); //The error message- Author:
- Daniele Strollo (ISTI-CNR)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Assertion()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidvalidate(boolean assertion, T exc)Makes an assertion and if the expression evaluation fails, throws an exception of type T.
-