From: David ‘Bombe’ Roden Date: Wed, 16 Jan 2013 10:52:39 +0000 (+0100) Subject: Replace utils’ ListBuilder by Guava’s ImmutableList.Builder. X-Git-Tag: 0.8.5^2~3^2~130 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=3ccb94d05fd21ab7f388bab9081d97f2157c13c8;p=Sone.git Replace utils’ ListBuilder by Guava’s ImmutableList.Builder. --- diff --git a/src/main/java/net/pterodactylus/sone/core/SoneInserter.java b/src/main/java/net/pterodactylus/sone/core/SoneInserter.java index 534985a..69d3db5 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneInserter.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneInserter.java @@ -20,7 +20,6 @@ package net.pterodactylus.sone.core; import java.io.InputStreamReader; import java.io.StringWriter; import java.nio.charset.Charset; -import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -28,14 +27,11 @@ import java.util.logging.Level; import java.util.logging.Logger; import net.pterodactylus.sone.data.Post; -import net.pterodactylus.sone.data.PostReply; import net.pterodactylus.sone.data.Reply; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.data.Sone.SoneStatus; import net.pterodactylus.sone.freenet.StringBucket; import net.pterodactylus.sone.main.SonePlugin; -import net.pterodactylus.util.collection.ListBuilder; -import net.pterodactylus.util.collection.ReverseComparator; import net.pterodactylus.util.io.Closer; import net.pterodactylus.util.logging.Logging; import net.pterodactylus.util.service.AbstractService; @@ -47,6 +43,9 @@ import net.pterodactylus.util.template.TemplateContextFactory; import net.pterodactylus.util.template.TemplateException; import net.pterodactylus.util.template.TemplateParser; import net.pterodactylus.util.template.XmlFilter; + +import com.google.common.collect.Ordering; + import freenet.client.async.ManifestElement; import freenet.keys.FreenetURI; @@ -302,8 +301,8 @@ public class SoneInserter extends AbstractService { soneProperties.put("requestUri", sone.getRequestUri()); soneProperties.put("insertUri", sone.getInsertUri()); soneProperties.put("profile", sone.getProfile()); - soneProperties.put("posts", new ListBuilder(new ArrayList(sone.getPosts())).sort(Post.TIME_COMPARATOR).get()); - soneProperties.put("replies", new ListBuilder(new ArrayList(sone.getReplies())).sort(new ReverseComparator>(Reply.TIME_COMPARATOR)).get()); + soneProperties.put("posts", Ordering.from(Post.TIME_COMPARATOR).sortedCopy(sone.getPosts())); + soneProperties.put("replies", Ordering.from(Reply.TIME_COMPARATOR).reverse().sortedCopy(sone.getReplies())); soneProperties.put("likedPostIds", new HashSet(sone.getLikedPostIds())); soneProperties.put("likedReplyIds", new HashSet(sone.getLikedReplyIds())); soneProperties.put("albums", sone.getAllAlbums()); diff --git a/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java b/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java index 4ef434f..8c74865 100644 --- a/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java +++ b/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java @@ -30,12 +30,14 @@ import net.pterodactylus.sone.main.SonePlugin; import net.pterodactylus.sone.notify.ListNotificationFilters; import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.sone.web.page.FreenetTemplatePage; -import net.pterodactylus.util.collection.ListBuilder; -import net.pterodactylus.util.collection.MapBuilder; import net.pterodactylus.util.notify.Notification; import net.pterodactylus.util.object.HashCode; import net.pterodactylus.util.template.Template; import net.pterodactylus.util.template.TemplateContext; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; + import freenet.clients.http.SessionManager.Session; import freenet.clients.http.ToadletContext; import freenet.support.api.HTTPRequest; @@ -217,7 +219,7 @@ public class SoneTemplatePage extends FreenetTemplatePage { */ @Override protected List> getAdditionalLinkNodes(FreenetRequest request) { - return new ListBuilder>().add(new MapBuilder().put("rel", "search").put("type", "application/opensearchdescription+xml").put("title", "Sone").put("href", "http://" + request.getHttpRequest().getHeader("host") + "/Sone/OpenSearch.xml").get()).get(); + return ImmutableList.> builder().add(ImmutableMap. builder().put("rel", "search").put("type", "application/opensearchdescription+xml").put("title", "Sone").put("href", "http://" + request.getHttpRequest().getHeader("host") + "/Sone/OpenSearch.xml").build()).build(); } /**