class JSExporterUtils {

    public static <T extends Activity> T findActivityIfExists(final SyncBeanManager beanManager,
                                                              String id,
                                                              Class<T> activityType) {
        Iterator<SyncBeanDef> existentActivities = beanManager.lookupBeans(id).iterator();
        while (existentActivities.hasNext()) {
            Object existentActivity = existentActivities.next().getInstance();
            if (activityType.equals(existentActivity.getClass())) {
                return (T) existentActivity;
            }
        }

        return null;
    }

}