public <S extends Exception, T extends TException> ExceptionHandler
      convertIfInstance(Class<S> source, Class<T> target) throws T {
    T targetException = null;
    if (source.isInstance(e)) {
      try {
        targetException = JavaUtils.newInstance(target,
            new Class[]{String.class}, new Object[]{e.getMessage()});
      } catch (Exception ex) {
        // This should not happen
        throw new RuntimeException(ex);
      }
    }
    if (targetException != null) {
      throw targetException;
    }
    return this;
  }
@Test
  public void testConvertIfInstance() {
    IOException ix = new IOException("IOException test");
    try {
      handleException(ix).convertIfInstance(NoSuchObjectException.class, MetaException.class);
    } catch (Exception e) {
      fail("Exception should not happen:" + e.getMessage());
    }

    try {
      handleException(ix).convertIfInstance(IOException.class, MetaException.class);
      fail("Should throw a exception here");
    } catch (Exception e) {
      assertTrue(e instanceof MetaException);
      assertTrue(e.getMessage().equals(ix.getMessage()));
    }

    try {
      handleException(ix).convertIfInstance(NoSuchObjectException.class, MetaException.class)
          .convertIfInstance(IOException.class, MetaException.class);
      fail("Should throw a exception here");
    } catch (Exception e) {
      assertTrue(e instanceof MetaException);
      assertTrue(e.getMessage().equals(ix.getMessage()));
    }
  }