Ejemplo n.º 1
0
 /**
  * @param object The object to invoke the method on.
  * @param checkMethodName The name of the check method which returns a boolean value.
  * @param expectedValue The expected value to be returned for the check to be enabled.
  */
 public PropertyEnableCheck(
     final Object object,
     final String checkMethodName,
     final Object expectedValue,
     ErrorHandler errorHandler) {
   Class clazz = object.getClass();
   this.object = object;
   this.expectedValue = expectedValue;
   this.errorHandler = errorHandler;
   try {
     method = clazz.getMethod(checkMethodName, new Class[] {});
   } catch (Throwable e) {
     errorHandler.handleThrowable(e);
   }
 }
Ejemplo n.º 2
0
 public String check(JComponent component) {
   try {
     Object result = method.invoke(object, new Object[0]);
     if (result == expectedValue) {
       return getResult(true);
     } else if (result == null) {
       return getResult(false);
     } else if (expectedValue == null) {
       return getResult(false);
     } else if (result.equals(expectedValue)) {
       return getResult(true);
     } else {
       return getResult(false);
     }
   } catch (Throwable e) {
     errorHandler.handleThrowable(e);
     return e.getMessage();
   }
 }
Ejemplo n.º 3
0
 public void report(Exception exception) {
   errorHandler.handleThrowable(exception);
 }