Replace utils’ Numbers by Guava’s Optional and Ints/Longs.tryParse.
[Sone.git] / src / main / java / net / pterodactylus / sone / web / NewPage.java
index 2d4ec55..af7c1ec 100644 (file)
@@ -28,10 +28,12 @@ import net.pterodactylus.sone.data.PostReply;
 import net.pterodactylus.sone.notify.ListNotificationFilters;
 import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.collection.Pagination;
-import net.pterodactylus.util.number.Numbers;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
 
+import com.google.common.base.Optional;
+import com.google.common.primitives.Ints;
+
 /**
  * Page that displays all new posts and replies. The posts are filtered using
  * {@link ListNotificationFilters#filterPosts(java.util.Collection, net.pterodactylus.sone.data.Sone)}
@@ -75,7 +77,7 @@ public class NewPage extends SoneTemplatePage {
                Collections.sort(sortedPosts, Post.TIME_COMPARATOR);
 
                /* paginate them. */
-               Pagination<Post> pagination = new Pagination<Post>(sortedPosts, webInterface.getCore().getPreferences().getPostsPerPage()).setPage(Numbers.safeParseInteger(request.getHttpRequest().getParam("page"), 0));
+               Pagination<Post> pagination = new Pagination<Post>(sortedPosts, webInterface.getCore().getPreferences().getPostsPerPage()).setPage(Optional.fromNullable(Ints.tryParse(request.getHttpRequest().getParam("page"))).or(0));
                templateContext.set("pagination", pagination);
                templateContext.set("posts", pagination.getItems());
        }