Revert "Replace utils’ Numbers by Guava’s Optional and Ints/Longs.tryParse."
[Sone.git] / src / main / java / net / pterodactylus / sone / web / SearchPage.java
index 355df1b..1bca8cd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - SearchPage.java - Copyright © 2010–2012 David Roden
+ * Sone - SearchPage.java - Copyright © 2010–2013 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
@@ -50,6 +50,7 @@ import com.google.common.cache.CacheLoader;
 import com.google.common.cache.LoadingCache;
 import com.google.common.collect.Collections2;
 import com.google.common.collect.FluentIterable;
+import com.google.common.collect.Ordering;
 
 /**
  * This page lets the user search for posts and replies that contain certain
@@ -96,6 +97,7 @@ public class SearchPage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
+       @SuppressWarnings("synthetic-access")
        protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
                super.processTemplate(request, templateContext);
                String query = request.getHttpRequest().getParam("query").trim();
@@ -138,10 +140,8 @@ public class SearchPage extends SoneTemplatePage {
                postHits = Collections2.filter(postHits, Hit.POSITIVE_FILTER);
 
                /* now sort. */
-               List<Hit<Sone>> sortedSoneHits = new ArrayList<Hit<Sone>>(soneHits);
-               Collections.sort(sortedSoneHits, Hit.DESCENDING_COMPARATOR);
-               List<Hit<Post>> sortedPostHits = new ArrayList<Hit<Post>>(postHits);
-               Collections.sort(sortedPostHits, Hit.DESCENDING_COMPARATOR);
+               List<Hit<Sone>> sortedSoneHits = Ordering.from(Hit.DESCENDING_COMPARATOR).sortedCopy(soneHits);
+               List<Hit<Post>> sortedPostHits = Ordering.from(Hit.DESCENDING_COMPARATOR).sortedCopy(postHits);
 
                /* extract Sones and posts. */
                List<Sone> resultSones = FluentIterable.from(sortedSoneHits).transform(new HitMapper<Sone>()).toList();
@@ -637,7 +637,7 @@ public class SearchPage extends SoneTemplatePage {
         *            The type of the object to extract
         * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
         */
-       public static class HitMapper<T> implements Function<Hit<T>, T> {
+       private static class HitMapper<T> implements Function<Hit<T>, T> {
 
                /**
                 * {@inheritDoc}