Assertion (Resource Management Library 2.0.0-2.17.1 API)
Date: 2014-01-09

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.gcube.resourcemanagement.support.server.utils
Class Assertion<T extends Throwable>

    java.lang.Object
      org.gcube.resourcemanagement.support.server.utils.Assertion<T>

All Implemented Interfaces:
  Serializable

    public class Assertion<T extends Throwable>

extends Object
implements Serializable

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
`Assertion()`

Method Summary
`void` | `validate(boolean assertion, T exc)` Makes an assertion and if the expression evaluation fails, throws an exception of type T.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Assertion

    public Assertion()

Method Detail

### validate

    public final void validate(boolean assertion,
                               T exc)
                        throws T extends Throwable

  Makes an assertion and if the expression evaluation fails, throws an exception of type T.

       Example:
              new Assertion<MyException>().validate(whatExpected, new MyException("guard failed"));

  Parameters:
    `assertion` - the boolean expression to evaluate
    `exc` - the exception to throw if the condition does not hold
  Throws:
    `T` - the exception extending `Throwable`
    `T extends Throwable`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2014. All Rights Reserved.