More use entrySet() rather than using keySet() and get(key)
This commit replaces some more occurrances of keySet() and get(key) with more efficient usage of the map's entry set. See gh-4813
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,11 +23,15 @@ import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
/**
|
||||
* A helper class generating a report from the meta-data of a particular service.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @author Andy Wilkinson
|
||||
* @since 1.2.0
|
||||
*/
|
||||
class ServiceCapabilitiesReportGenerator {
|
||||
@@ -104,11 +108,20 @@ class ServiceCapabilitiesReportGenerator {
|
||||
StringBuilder report) {
|
||||
report.append("Available project types:" + NEW_LINE);
|
||||
report.append("------------------------" + NEW_LINE);
|
||||
List<String> typeIds = new ArrayList<String>(metadata.getProjectTypes().keySet());
|
||||
Collections.sort(typeIds);
|
||||
for (String typeId : typeIds) {
|
||||
ProjectType type = metadata.getProjectTypes().get(typeId);
|
||||
report.append(typeId + " - " + type.getName());
|
||||
SortedSet<Entry<String, ProjectType>> entries = new TreeSet<Entry<String, ProjectType>>(
|
||||
new Comparator<Entry<String, ProjectType>>() {
|
||||
|
||||
@Override
|
||||
public int compare(Entry<String, ProjectType> o1,
|
||||
Entry<String, ProjectType> o2) {
|
||||
return o1.getKey().compareTo(o2.getKey());
|
||||
}
|
||||
|
||||
});
|
||||
entries.addAll(metadata.getProjectTypes().entrySet());
|
||||
for (Entry<String, ProjectType> entry : entries) {
|
||||
ProjectType type = entry.getValue();
|
||||
report.append(entry.getKey() + " - " + type.getName());
|
||||
if (!type.getTags().isEmpty()) {
|
||||
reportTags(report, type);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user