/** * Checks that a callback method is present and correctly defined. * * <p>Having checked it, you can call it using callback(). * * @param sCallback Name of callback method * @throws OmDeveloperException If the method doesn't exist or is defined incorrectly */ public void checkCallback(String sCallback) throws OmDeveloperException { try { Method m = getClass().getMethod(sCallback, new Class[0]); if (m.getReturnType() != void.class) throw new OmDeveloperException("Callback method " + sCallback + "() must return void"); if (!Modifier.isPublic(m.getModifiers())) throw new OmDeveloperException("Callback method " + sCallback + "() must be public"); if (Modifier.isStatic(m.getModifiers())) throw new OmDeveloperException("Callback method " + sCallback + "() may not be static"); if (Modifier.isAbstract(m.getModifiers())) throw new OmDeveloperException("Callback method " + sCallback + "() may not be abstract"); sCheckedCallbacks.add(sCallback); } catch (NoSuchMethodException e) { throw new OmDeveloperException("Callback method " + sCallback + "() does not exist"); } }