@Override public StatisticsBuilder getBuilder(Class<? extends Statistics> statisticsClass) { for (StatisticsBuilder b : statisticsBuilders) { if (b.getStatisticsClass().equals(statisticsClass)) { return b; } } return null; }
@Override public void execute(final Statistics statistics, LongTaskListener listener) { StatisticsBuilder builder = getBuilder(statistics.getClass()); LongTaskExecutor executor = new LongTaskExecutor(true, "Statistics " + builder.getName(), 10); if (listener != null) { executor.setLongTaskListener(listener); } if (statistics instanceof DynamicStatistics) { final DynamicLongTask dynamicLongTask = new DynamicLongTask((DynamicStatistics) statistics); executor.execute( dynamicLongTask, new Runnable() { @Override public void run() { executeDynamic((DynamicStatistics) statistics, dynamicLongTask); } }, builder.getName(), null); } else { LongTask task = statistics instanceof LongTask ? (LongTask) statistics : null; executor.execute( task, new Runnable() { @Override public void run() { execute(statistics); } }, builder.getName(), null); } }