01: package org.andromda.translation.ocl.validation;
02:
03: /**
04: * <p/>
05: * Ensures that the result of the OCL expression is a boolean value. This is necessary because some expressions' results
06: * will actually be wrapped in an instance of <code>java.lang.Object</code> because of the fact that OCLIntropector is
07: * used. </p>
08: *
09: * @author Chad Brandon
10: */
11: public final class OCLResultEnsurer {
12: /**
13: * Does nothing but return the passed in <code>result</code> argument.
14: *
15: * @param result the result.
16: * @return the boolean result.
17: */
18: public static boolean ensure(boolean result) {
19: return result;
20: }
21:
22: /**
23: * Converts the passed in <code>result</code> to a <code>boolean</code> value and returns it. If <code>result</code>
24: * is null, false will be assumed.
25: *
26: * @param result
27: * @return the boolean result.
28: */
29: public static boolean ensure(Object result) {
30: return result != null
31: && Boolean.valueOf(result.toString()).booleanValue();
32: }
33: }
|