KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > easymock > internal > Result


1 /*
2  * Copyright (c) 2001-2005 OFFIS. This program is made available under the terms of
3  * the MIT License.
4  */

5 package org.easymock.internal;
6
7 public class Result {
8     private Object JavaDoc value;
9
10     private boolean doThrow;
11
12     private Result(Object JavaDoc value, boolean doThrow) {
13         this.value = value;
14         this.doThrow = doThrow;
15     }
16
17     public static Result createThrowResult(Throwable JavaDoc throwable) {
18         return new Result(throwable, true);
19     }
20
21     public static Result createReturnResult(Object JavaDoc value) {
22         return new Result(value, false);
23     }
24
25     public Object JavaDoc returnObjectOrThrowException() throws Throwable JavaDoc {
26         if (doThrow) {
27             throw new ThrowableWrapper((Throwable JavaDoc) value);
28         } else {
29             return value;
30         }
31     }
32 }
33
Popular Tags