17 |
ilm |
1 |
/*
|
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
|
|
3 |
*
|
|
|
4 |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
|
|
|
5 |
*
|
|
|
6 |
* The contents of this file are subject to the terms of the GNU General Public License Version 3
|
|
|
7 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
|
|
|
8 |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
|
|
|
9 |
* language governing permissions and limitations under the License.
|
|
|
10 |
*
|
|
|
11 |
* When distributing the software, include this License Header Notice in each file.
|
|
|
12 |
*/
|
|
|
13 |
|
|
|
14 |
package org.openconcerto.utils.cc;
|
|
|
15 |
|
|
|
16 |
/**
|
|
|
17 |
* Closure able to throw an exception.
|
|
|
18 |
*
|
|
|
19 |
* @author Sylvain
|
|
|
20 |
*
|
|
|
21 |
* @param <E> input type
|
|
|
22 |
* @param <X> exception type
|
|
|
23 |
*/
|
83 |
ilm |
24 |
public abstract class ExnClosure<E, X extends Exception> extends ExnTransformer<E, Object, X> implements IExnClosure<E, X> {
|
17 |
ilm |
25 |
|
|
|
26 |
/**
|
83 |
ilm |
27 |
* Execute this closure, making sure that an exception of type <code>exnClass</code> is thrown.
|
17 |
ilm |
28 |
*
|
|
|
29 |
* @param <Y> type of exception to throw.
|
|
|
30 |
* @param input the input of the closure.
|
|
|
31 |
* @param exnClass class exception to throw.
|
|
|
32 |
* @throws Y if {@link #executeChecked(Object)} throws an exception, it will be wrapped (if
|
|
|
33 |
* necessary) in an exception of class <code>exnClass</code>.
|
|
|
34 |
*/
|
|
|
35 |
public final <Y extends Exception> void executeCheckedWithExn(E input, Class<Y> exnClass) throws Y {
|
|
|
36 |
this.transformCheckedWithExn(input, exnClass);
|
|
|
37 |
}
|
|
|
38 |
|
|
|
39 |
@Override
|
|
|
40 |
public final Object transformChecked(E input) throws X {
|
|
|
41 |
this.executeChecked(input);
|
|
|
42 |
return null;
|
|
|
43 |
}
|
|
|
44 |
|
83 |
ilm |
45 |
@Override
|
17 |
ilm |
46 |
public abstract void executeChecked(E input) throws X;
|
|
|
47 |
}
|