Source:
<code>public List<MetricDto> getMetrics(List<MetricNameDto> metricNames) { long temp = System.currentTimeMillis(); List<MetricDto> result = new ArrayList<MetricDto>(metricNames.size()); standardMetricSummaryFetcher.reset(); durationMetricSummaryFetcher.reset(); latencyMetricDataFetcher.reset(); customMetricSummaryFetcher.reset(); validatorSummaryFetcher.reset(); for (MetricNameDto metricName : metricNames){ switch (metricName.getOrigin()) { case STANDARD_METRICS: standardMetricSummaryFetcher.addMetricName(metricName); break; case DURATION: durationMetricSummaryFetcher.addMetricName(metricName); break; case LATENCY_PERCENTILE: latencyMetricDataFetcher.addMetricName(metricName); break; case METRIC: customMetricSummaryFetcher.addMetricName(metricName); break; case VALIDATOR: validatorSummaryFetcher.addMetricName(metricName); <START> break; <END> } } List<MetricDataFetcher<MetricDto>> fetcherList = new ArrayList<MetricDataFetcher<MetricDto>>(); fetcherList.add(standardMetricSummaryFetcher); fetcherList.add(durationMetricSummaryFetcher); fetcherList.add(latencyMetricDataFetcher); fetcherList.add(customMetricSummaryFetcher); fetcherList.add(validatorSummaryFetcher); List<Future<Set<MetricDto>>> futures = new ArrayList<Future<Set<MetricDto>>>(); for (final MetricDataFetcher<MetricDto> fetcher : fetcherList) { futures.add(threadPool.submit(new Callable<Set<MetricDto>>() { @Override public Set<MetricDto> call() throws Exception { return fetcher.getResult(); } })); } try { for (Future<Set<MetricDto>> future : futures) { result.addAll(future.get()); } } catch (Throwable th) { th.printStackTrace(); log.error("Exception while summary retrieving", th); } log.debug("{} ms spent for fetching summary data for metrics", System.currentTimeMillis() - temp, metricNames.size()); return result; }</code><technical_language>switch enum values</technical_language>

Target:
public List<MetricDto> getMetrics(List<MetricNameDto> metricNames) { long temp = System.currentTimeMillis(); List<MetricDto> result = new ArrayList<MetricDto>(metricNames.size()); final Multimap<MetricDataFetcher<MetricDto>, MetricNameDto> fetchMap = ArrayListMultimap.create(); for (MetricNameDto metricName : metricNames){ switch (metricName.getOrigin()) { case STANDARD_METRICS: fetchMap.put(standardMetricSummaryFetcher, metricName); break; case DURATION: fetchMap.put(durationMetricSummaryFetcher, metricName); break; case LATENCY_PERCENTILE: fetchMap.put(latencyMetricDataFetcher, metricName); break; case METRIC: fetchMap.put(customMetricSummaryFetcher, metricName); break; case VALIDATOR: fetchMap.put(validatorSummaryFetcher, metricName); break; default: log.error("MetricNameDto with origin : appears in metric name list for summary retrieving ({})", metricName.getOrigin(), metricName); throw new RuntimeException("Unable to get summary data for metric " + metricName.getMetricName() + " with origin: " + metricName.getOrigin()); } } Set<MetricDataFetcher<MetricDto>> fetcherSet = fetchMap.keySet(); List<Future<Set<MetricDto>>> futures = new ArrayList<Future<Set<MetricDto>>>(); for (final MetricDataFetcher<MetricDto> fetcher : fetcherSet) { futures.add(threadPool.submit(new Callable<Set<MetricDto>>() { @Override public Set<MetricDto> call() throws Exception { return fetcher.getResult(new ArrayList<MetricNameDto>(fetchMap.get(fetcher))); } })); } try { for (Future<Set<MetricDto>> future : futures) { result.addAll(future.get()); } } catch (Throwable th) { th.printStackTrace(); log.error("Exception while summary retrieving", th); } log.debug("{} ms spent for fetching summary data for metrics", System.currentTimeMillis() - temp, metricNames.size()); return result; }