Use a statically created Comparator
@@ -55,6 +55,9 @@ public final class SourceManifestAction extends AbstractFileWriteAction {
private static final String GUID = "07459553-a3d0-4d37-9d78-18ed942470f4";
+ private static final Comparator<Map.Entry<PathFragment, Artifact>> ENTRY_COMPARATOR =
+ (path1, path2) -> path1.getKey().compareTo(path2.getKey());
+
/**
* Interface for defining manifest formatting and reporting specifics. Implementations must be
* immutable.
@@ -168,18 +171,8 @@ public final class SourceManifestAction extends AbstractFileWriteAction {
*/
private void writeFile(OutputStream out, Map<PathFragment, Artifact> output) throws IOException {
Writer manifestFile = new BufferedWriter(new OutputStreamWriter(out, ISO_8859_1));
-
- Comparator<Map.Entry<PathFragment, Artifact>> fragmentComparator =
- new Comparator<Map.Entry<PathFragment, Artifact>>() {
- @Override
- public int compare(Map.Entry<PathFragment, Artifact> path1,
- Map.Entry<PathFragment, Artifact> path2) {
- return path1.getKey().compareTo(path2.getKey());
- }
- };
-
List<Map.Entry<PathFragment, Artifact>> sortedManifest = new ArrayList<>(output.entrySet());
- Collections.sort(sortedManifest, fragmentComparator);
+ Collections.sort(sortedManifest, ENTRY_COMPARATOR);
for (Map.Entry<PathFragment, Artifact> line : sortedManifest) {
manifestWriter.writeEntry(manifestFile, line.getKey(), line.getValue());
