🔀 Merge branch 'release/v82'
[Sone.git] / src / main / java / net / pterodactylus / sone / fcp / GetSonesCommand.java
index 10595ff..eedf120 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - GetSonesCommand.java - Copyright © 2011–2016 David Roden
+ * Sone - GetSonesCommand.java - Copyright © 2011–2020 David Roden
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
 
 package net.pterodactylus.sone.fcp;
 
+import static net.pterodactylus.sone.data.SoneKt.*;
+import static net.pterodactylus.sone.fcp.AbstractSoneCommandKt.encodeSones;
+
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
 import net.pterodactylus.sone.core.Core;
-import net.pterodactylus.sone.data.Sone;
+import net.pterodactylus.sone.data.*;
+
 import freenet.support.SimpleFieldSet;
 
 /**
  * Implements the “GetSones” FCP command that returns the list of known Sones.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
  */
 public class GetSonesCommand extends AbstractSoneCommand {
 
@@ -49,12 +51,12 @@ public class GetSonesCommand extends AbstractSoneCommand {
        public Response execute(SimpleFieldSet parameters) {
                int startSone = getInt(parameters, "StartSone", 0);
                int maxSones = getInt(parameters, "MaxSones", -1);
-               List<Sone> sones = new ArrayList<Sone>(getCore().getSones());
+               List<Sone> sones = new ArrayList<>(getCore().getSones());
                if (sones.size() < startSone) {
-                       return new Response("Sones", encodeSones(Collections.<Sone> emptyList(), ""));
+                       return new Response("Sones", encodeSones(Collections.<Sone> emptyList(), "Sones."));
                }
-               Collections.sort(sones, Sone.NICE_NAME_COMPARATOR);
-               return new Response("Sones", encodeSones(sones.subList(startSone, (maxSones == -1) ? sones.size() : Math.min(startSone + maxSones, sones.size())), ""));
+               sones.sort(niceNameComparator());
+               return new Response("Sones", encodeSones(sones.subList(startSone, (maxSones == -1) ? sones.size() : Math.min(startSone + maxSones, sones.size())), "Sones."));
        }
 
 }