private void addAll (final @Nonnull List<JobEventSpi> results, final @Nonnull List<? extends JobEvent> jobEvents) { for (final JobEvent jobEvent : jobEvents) { if (jobEvent instanceof JobEventGroup) { addAll(results, ((JobEventGroup)jobEvent).findChildren().results()); } else { results.add((JobEventSpi)jobEvent); } } } }
/******************************************************************************************************************* * * Retrieves the hourly rates - if missing from the project description, tries to recover it from the first * meaningful job event. * ******************************************************************************************************************/ @Nonnull private Money getHourlyRate(final ConfigurationDecorator projectConfig, final List<JobEvent> jobEvents) throws NotFoundException { Money hourlyRate = projectConfig.getMoney("projectRate"); if ((hourlyRate.compareTo(Money.ZERO) == 0) && !jobEvents.isEmpty()) // don't use equals() - see http://stackoverflow.com/questions/6787142/bigdecimal-equals-versus-compareto { JobEvent event = jobEvents.get(0); while ((event instanceof JobEventGroup) && ((JobEventGroup)event).findChildren().count() > 0) { event = ((JobEventGroup)event).findChildren().firstResult(); } if (event instanceof TimedJobEventSpi) { hourlyRate = ((TimedJobEventSpi)event).getHourlyRate(); } } return hourlyRate; }
private void dump (final @Nonnull JobEvent event, final @Nonnull String prefix) { pw.printf("%s%s\n", prefix, toString(event)); if (event instanceof JobEventGroup) { dump(((JobEventGroup)event).findChildren(), prefix + INDENT); } }